Skip to content

Commit d85addb

Browse files
feat(spring-databases-example): adjustments
1 parent 57747c5 commit d85addb

File tree

10 files changed

+149
-8
lines changed

10 files changed

+149
-8
lines changed

spring-mysql-example/.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
target/
2+
.mvn/wrapper/maven-wrapper.jar
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
5+
6+
### STS ###
7+
.apt_generated
8+
.classpath
9+
.factorypath
10+
.project
11+
.settings
12+
.springBeans
13+
.sts4-cache
14+
15+
### IntelliJ IDEA ###
16+
.idea
17+
*.iws
18+
*.iml
19+
*.ipr
20+
21+
### NetBeans ###
22+
/nbproject/private/
23+
/nbbuild/
24+
/dist/
25+
/nbdist/
26+
/.nb-gradle/
27+
build/
28+
!**/src/main/**/build/
29+
!**/src/test/**/build/
30+
31+
### VS Code ###
32+
.vscode/

spring-mysql-example/compose.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ services:
88
ports:
99
- "8080:8080"
1010
environment:
11-
SPRING_DATASOURCE_URL: jdbc:mysql://mysql-container:3306/myapp_db?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
11+
SPRING_PROFILES_ACTIVE: prd
12+
SPRING_DATASOURCE_URL: jdbc:mysql://mysql-db:3306/myapp_db?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
1213
SPRING_DATASOURCE_USERNAME: myapp_user
1314
SPRING_DATASOURCE_PASSWORD: user123
1415
SPRING_DATASOURCE_DRIVER: com.mysql.cj.jdbc.Driver
1516
SPRING_JPA_HIBERNATE_DDL_AUTO: none
1617
SPRING_JPA_SHOW_SQL: false
1718

18-
mysql:
19+
mysql-db:
1920
image: mysql:8.1
20-
container_name: mysql-container
21+
container_name: mysql-db
2122
ports:
2223
- "3306:3306"
2324
environment:

spring-oracle-example/.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
target/
2+
.mvn/wrapper/maven-wrapper.jar
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
5+
6+
### STS ###
7+
.apt_generated
8+
.classpath
9+
.factorypath
10+
.project
11+
.settings
12+
.springBeans
13+
.sts4-cache
14+
15+
### IntelliJ IDEA ###
16+
.idea
17+
*.iws
18+
*.iml
19+
*.ipr
20+
21+
### NetBeans ###
22+
/nbproject/private/
23+
/nbbuild/
24+
/dist/
25+
/nbdist/
26+
/.nb-gradle/
27+
build/
28+
!**/src/main/**/build/
29+
!**/src/test/**/build/
30+
31+
### VS Code ###
32+
.vscode/

spring-oracle-example/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ USER appuser
3434
COPY --from=package build/target/app.jar app.jar
3535

3636
COPY docker/java/entrypoint.sh /entrypoint.sh
37+
USER root
3738
RUN chmod +x /entrypoint.sh
39+
USER appuser
3840

3941
EXPOSE 8082
4042

spring-oracle-example/compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
ports:
88
- "8082:8082"
99
environment:
10-
SPRING_PROFILES_ACTIVE: default
10+
SPRING_PROFILES_ACTIVE: prd
1111
SERVER_PORT: 8082
1212
SPRING_DATASOURCE_URL: jdbc:oracle:thin:@oracle-db:1521
1313
SPRING_DATASOURCE_USERNAME: developer

spring-oracle-example/docker/java/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ echo "Waiting 30 seconds..."
55
sleep 30
66

77
echo "Starting the application..."
8-
exec java org.springframework.boot.loader.launch.JarLauncher
8+
exec java -jar app.jar

spring-postgres-example/.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
target/
2+
.mvn/wrapper/maven-wrapper.jar
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
5+
6+
### STS ###
7+
.apt_generated
8+
.classpath
9+
.factorypath
10+
.project
11+
.settings
12+
.springBeans
13+
.sts4-cache
14+
15+
### IntelliJ IDEA ###
16+
.idea
17+
*.iws
18+
*.iml
19+
*.ipr
20+
21+
### NetBeans ###
22+
/nbproject/private/
23+
/nbbuild/
24+
/dist/
25+
/nbdist/
26+
/.nb-gradle/
27+
build/
28+
!**/src/main/**/build/
29+
!**/src/test/**/build/
30+
31+
### VS Code ###
32+
.vscode/

spring-postgres-example/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ COPY --from=package build/target/app.jar app.jar
3535

3636
EXPOSE 8081
3737

38-
ENTRYPOINT [ "java", "-jar", "app.jar" ]
38+
ENTRYPOINT [ "java", "-jar", "app.jar" ]

spring-postgres-example/compose.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,18 @@ services:
66
context: .
77
ports:
88
- "8081:8081"
9+
environment:
10+
SPRING_PROFILES_ACTIVE: prd
11+
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres-db:5432/myapp_db
12+
SPRING_DATASOURCE_USERNAME: myapp_user
13+
SPRING_DATASOURCE_PASSWORD: user123
14+
SPRING_DATASOURCE_DRIVER: org.postgresql.Driver
15+
SPRING_JPA_HIBERNATE_DDL_AUTO: none
16+
SPRING_JPA_SHOW_SQL: false
917

10-
postgres:
18+
postgres-db:
1119
image: postgres:17
12-
container_name: postgres-container
20+
container_name: postgres-db
1321
ports:
1422
- "5432:5432"
1523
environment:

spring-postgres-example/pom.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,40 @@
6262

6363
</dependencies>
6464

65+
<build>
66+
<plugins>
67+
68+
<plugin>
69+
<groupId>org.apache.maven.plugins</groupId>
70+
<artifactId>maven-compiler-plugin</artifactId>
71+
<version>${maven.compiler.plugin.version}</version>
72+
<configuration>
73+
<annotationProcessorPaths>
74+
<path>
75+
<groupId>org.projectlombok</groupId>
76+
<artifactId>lombok</artifactId>
77+
</path>
78+
</annotationProcessorPaths>
79+
</configuration>
80+
</plugin>
81+
82+
<plugin>
83+
<groupId>org.springframework.boot</groupId>
84+
<artifactId>spring-boot-maven-plugin</artifactId>
85+
<version>${spring.boot.version}</version>
86+
<configuration>
87+
<excludes>
88+
<exclude>
89+
<groupId>org.projectlombok</groupId>
90+
<artifactId>lombok</artifactId>
91+
</exclude>
92+
</excludes>
93+
</configuration>
94+
</plugin>
95+
96+
</plugins>
97+
98+
</build>
6599

66100
</project>
67101

0 commit comments

Comments
 (0)