Skip to content

Commit bb3f9d3

Browse files
author
Adnane Miliari
committed
✨refactor: centralize configuration management with shared yaml files
1 parent 80b45eb commit bb3f9d3

33 files changed

+258
-697
lines changed

common/pom.xml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<parent>
4+
<artifactId>demo-microservices</artifactId>
5+
<groupId>dev.nano</groupId>
6+
<version>1.0-SNAPSHOT</version>
7+
</parent>
8+
9+
<modelVersion>4.0.0</modelVersion>
10+
<artifactId>common</artifactId>
11+
12+
<dependencies>
13+
<dependency>
14+
<groupId>org.springframework.boot</groupId>
15+
<artifactId>spring-boot-starter-web</artifactId>
16+
</dependency>
17+
<dependency>
18+
<groupId>org.springframework.boot</groupId>
19+
<artifactId>spring-boot-starter-data-jpa</artifactId>
20+
</dependency>
21+
<dependency>
22+
<groupId>org.springframework.cloud</groupId>
23+
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
24+
</dependency>
25+
<dependency>
26+
<groupId>io.micrometer</groupId>
27+
<artifactId>micrometer-tracing-bridge-brave</artifactId>
28+
</dependency>
29+
<dependency>
30+
<groupId>io.zipkin.reporter2</groupId>
31+
<artifactId>zipkin-reporter-brave</artifactId>
32+
</dependency>
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-starter-actuator</artifactId>
36+
</dependency>
37+
</dependencies>
38+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
management:
2+
observations:
3+
key-values:
4+
application: ${spring.application.name}
5+
tracing:
6+
sampling:
7+
probability: 1.0
8+
enabled: true
9+
zipkin:
10+
tracing:
11+
endpoint: http://localhost:9411/api/v2/spans
12+
endpoints:
13+
web:
14+
exposure:
15+
include: "*"
16+
endpoint:
17+
health:
18+
show-details: always
19+
20+
spring:
21+
datasource:
22+
url: jdbc:postgresql://localhost:5432/${spring.application.name}
23+
username: postgres
24+
password: password
25+
jpa:
26+
hibernate:
27+
ddl-auto: create-drop
28+
properties:
29+
hibernate:
30+
dialect: org.hibernate.dialect.PostgreSQLDialect
31+
format_sql: true
32+
show-sql: true
33+
open-in-view: false
34+
rabbitmq:
35+
addresses: localhost:5672
36+
37+
eureka:
38+
client:
39+
service-url:
40+
defaultZone: http://localhost:8761/eureka
41+
fetch-registry: true
42+
register-with-eureka: true
43+
44+
logging:
45+
pattern:
46+
correlation: "[${spring.application.name:},%X{traceId:-},%X{spanId:-}]"
47+
level: "%5p ${logging.pattern.correlation} %c{1.} : %m%n"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
management:
2+
zipkin:
3+
tracing:
4+
endpoint: http://zipkin:9411/api/v2/spans
5+
6+
spring:
7+
datasource:
8+
url: jdbc:postgresql://postgres:5432/${spring.application.name}
9+
username: miliariadnane
10+
password: password
11+
rabbitmq:
12+
addresses: rabbitmq:5672
13+
14+
eureka:
15+
client:
16+
service-url:
17+
defaultZone: http://eureka-server:8761/eureka
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
management:
2+
zipkin:
3+
tracing:
4+
endpoint: http://zipkin:9411/api/v2/spans
5+
6+
spring:
7+
datasource:
8+
url: jdbc:postgresql://demo-microservices.csetxdk14qax.us-east-1.rds.amazonaws.com:5432/${spring.application.name}
9+
username: ${DB_USERNAME}
10+
password: ${DB_PASSWORD}
11+
rabbitmq:
12+
addresses: rabbitmq:5672
13+
jpa:
14+
hibernate:
15+
ddl-auto: update
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
management:
2+
zipkin:
3+
tracing:
4+
endpoint: http://zipkin:9411/api/v2/spans
5+
6+
spring:
7+
datasource:
8+
url: jdbc:postgresql://postgres:5432/${spring.application.name}
9+
username: miliariadnane
10+
password: password
11+
rabbitmq:
12+
addresses: rabbitmq:5672
13+
14+
eureka:
15+
client:
16+
service-url:
17+
defaultZone: http://eureka-server:8761/eureka
18+
enabled: false

customer/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@
5959
<artifactId>spring-boot-starter-test</artifactId>
6060
<scope>test</scope>
6161
</dependency>
62+
<dependency>
63+
<groupId>dev.nano</groupId>
64+
<artifactId>common</artifactId>
65+
<version>${project.version}</version>
66+
</dependency>
6267
<dependency>
6368
<groupId>dev.nano</groupId>
6469
<artifactId>amqp</artifactId>

customer/src/main/resources/application-docker.yml

-44
This file was deleted.

customer/src/main/resources/application-eks.yml

-37
This file was deleted.

customer/src/main/resources/application-kube.yml

-45
This file was deleted.
+4-40
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,12 @@
1-
#Server
21
server:
32
port: 8001
43
servlet:
54
context-path: /customer
65
error:
7-
include-message: always
8-
#Management
9-
management:
10-
endpoints:
11-
web:
12-
exposure:
13-
include: "*"
14-
endpoint:
15-
health:
16-
show-details: always
17-
#Spring
6+
include-message: always
7+
188
spring:
199
application:
2010
name: customer
21-
datasource:
22-
url: jdbc:postgresql://localhost:5432/customer
23-
username: postgres
24-
password: password
25-
zipkin:
26-
base-url: http://localhost:9411
27-
rabbitmq:
28-
addresses: localhost:5672 # not http, because is a message queue protocol
29-
jpa:
30-
hibernate:
31-
ddl-auto: create-drop
32-
properties:
33-
hibernate:
34-
dialect: org.hibernate.dialect.PostgreSQLDialect
35-
format_sql: true
36-
show-sql: true
37-
#Eureka-Client
38-
eureka:
39-
client:
40-
service-url:
41-
defaultZone: http://localhost:8761/eureka
42-
fetch-registry: true
43-
register-with-eureka: true
44-
logging:
45-
pattern:
46-
# Logging pattern containing traceId and spanId; no longer provided through Sleuth by default
47-
level: "%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]"
48-
11+
config:
12+
import: classpath:shared-application-${spring.profiles.active}.yml

eureka-server/src/main/resources/application-docker.yml

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
11
#Server
22
server:
33
port: 8761
4+
45
#Spring
56
spring:
67
application:
78
name: eureka-server
8-
zipkin:
9-
baseUrl: http://zipkin:9411
9+
1010
#Management
1111
management:
12+
observations:
13+
key-values:
14+
application: ${spring.application.name}
15+
tracing:
16+
sampling:
17+
probability: 1.0
18+
enabled: true
19+
zipkin:
20+
tracing:
21+
endpoint: http://zipkin:9411/api/v2/spans
1222
endpoints:
1323
web:
1424
exposure:
1525
include: "*"
1626
endpoint:
1727
health:
1828
show-details: always
29+
1930
#Eureka-Server
2031
eureka:
2132
client:

0 commit comments

Comments
 (0)