Skip to content

Commit 8c1d6cf

Browse files
committed
refactor(config): consolidate shared yml properties into application.yml
Move duplicated configuration from dev and prod profiles into the base application.yml, keeping only profile-specific overrides in each file. - Move ddl-auto: validate to base (identical in both profiles) - Move flyway default-schema and schemas to base - Move cache.type, redis port/timeout/pool/repositories to base - Move task.scheduling.pool.size to base - Move tracing.propagation.type: w3c to base - Keep redis min-idle per profile (0 in dev, 2 in prod) - Remove ddl-auto: update concern — dev was already using validate
1 parent eca259c commit 8c1d6cf

File tree

3 files changed

+46
-71
lines changed

3 files changed

+46
-71
lines changed

src/main/resources/application-dev.yml

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,24 @@ spring:
55
password: ${DB_PASSWORD:postgres}
66

77
jpa:
8-
hibernate:
9-
ddl-auto: validate
108
show-sql: true
119
properties:
1210
hibernate:
1311
'[format_sql]': true
1412

1513
# Flyway
1614
flyway:
17-
enabled: true
18-
baseline-on-migrate: true
19-
default-schema: public # ← Flyway sempre usa public
20-
schemas: public # ← Flyway só gerencia public
2115
locations:
2216
- classpath:db/migration/common
2317
- classpath:db/migration/dev
2418

2519
# Redis
26-
cache:
27-
type: redis
2820
data:
2921
redis:
3022
host: ${REDIS_HOST:localhost}
31-
port: 6379
32-
timeout: 60000
3323
lettuce:
3424
pool:
35-
max-active: 8
36-
max-idle: 8
3725
min-idle: 0
38-
repositories:
39-
enabled: false
40-
41-
# ═══════════════════════════════════════════════════════════════════
42-
# SCHEDULED TASKS
43-
# ═══════════════════════════════════════════════════════════════════
44-
task:
45-
scheduling:
46-
pool:
47-
# Número de threads para tarefas agendadas
48-
size: 2
49-
50-
# Configuração do cleanup job (opcional - customizar cron)
51-
# refresh-token:
52-
# cleanup:
53-
# # Cron: todo dia às 2h AM
54-
# cron: 0 0 2 * * *
55-
# # Alternativas:
56-
# # - A cada hora: 0 0 * * * *
57-
# # - A cada 6 horas: 0 0 */6 * * *
58-
# # - Toda segunda às 3h AM: 0 0 3 * * MON
5926

6027
# ═══════════════════════════════════════════════════════════════════
6128
# TRACING — Micrometer + OpenTelemetry
@@ -65,12 +32,9 @@ management:
6532
tracing:
6633
sampling:
6734
probability: 1.0 # 100% das requisições rastreadas em dev
68-
propagation:
69-
type: w3c # W3C Trace Context — padrão interoperável
7035
export:
7136
zipkin:
7237
endpoint: http://localhost:9411/api/v2/spans # Zipkin local (docker-compose.dev.yml)
73-
7438
endpoints:
7539
web:
7640
exposure:

src/main/resources/application-prod.yml

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
spring:
22
datasource:
3-
url: ${DB_URL} #usar postgres no docker, localhost localmente
3+
url: ${DB_URL} #usar postgres no docker, localhost local
44
username: ${DB_USERNAME}
55
password: ${DB_PASSWORD}
66

@@ -15,53 +15,31 @@ spring:
1515

1616
# JPA/Hibernate
1717
jpa:
18-
hibernate:
19-
ddl-auto: validate
2018
show-sql: false
2119

2220
# Flyway
2321
flyway:
24-
enabled: true
25-
baseline-on-migrate: true
26-
default-schema: public
27-
schemas: public
2822
locations:
2923
- classpath:db/migration/common
3024
clean-disabled: true
3125

3226
# Redis
33-
cache:
34-
type: redis
3527
data:
3628
redis:
3729
host: ${REDIS_HOST:redis}
3830
port: ${REDIS_PORT:6379}
39-
timeout: 60000
4031
lettuce:
4132
pool:
42-
max-active: 8
43-
max-idle: 8
4433
min-idle: 2
45-
repositories:
46-
enabled: false
4734

48-
# SCHEDULED TASKS
49-
task:
50-
scheduling:
51-
pool:
52-
size: 2
53-
54-
# TRACING — Micrometer + OpenTelemetry
35+
# TRACING — Micrometer + OpenTelemetry + Actuator
5536
management:
5637
tracing:
5738
sampling:
5839
probability: ${TRACING_SAMPLING_PROBABILITY:0.1} # 10% em prod — ajustável via env
59-
propagation:
60-
type: w3c
6140
export:
6241
zipkin:
6342
endpoint: ${ZIPKIN_ENDPOINT:http://zipkin:9411/api/v2/spans}
64-
6543
endpoints:
6644
web:
6745
exposure:
@@ -101,11 +79,6 @@ springdoc:
10179

10280
# Configurações de segurança e JWT
10381
jwt:
104-
# Prod: SEMPRE usar variável de ambiente
10582
secret-key: ${JWT_SECRET_KEY}
106-
107-
# Prod: access token de 15 minutos (mais seguro)
10883
access-token-seconds: ${JWT_ACCESS_TOKEN-SECONDS:900}
109-
110-
# Prod: refresh token de 7 dias
11184
refresh-token-days: ${JWT_REFRESH_TOKEN_DAYS:7}

src/main/resources/application.yml

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
spring:
22
application:
33
name: library
4-
4+
5+
profiles:
6+
active: ${SPRING_PROFILES_ACTIVE:dev}
7+
8+
# JPA/Hibernate
59
jpa:
610
open-in-view: false
11+
hibernate:
12+
ddl-auto: validate
713
properties:
814
hibernate:
915
'[default_schema]': public
@@ -15,38 +21,70 @@ spring:
1521
datasource:
1622
hikari:
1723
connection-init-sql: SET search_path TO auth,catalog,lending,public
18-
24+
25+
# Flyway
26+
flyway:
27+
enabled: true
28+
baseline-on-migrate: true
29+
default-schema: public # ← Flyway sempre usa public
30+
schemas: public # ← Flyway só gerencia public
31+
32+
# Redis
33+
cache:
34+
type: redis
35+
data:
36+
redis:
37+
port: 6379
38+
timeout: 60000
39+
lettuce:
40+
pool:
41+
max-active: 8
42+
max-idle: 8
43+
repositories:
44+
enabled: false
45+
46+
# SCHEDULED TASKS
47+
task:
48+
scheduling:
49+
pool:
50+
size: 2
51+
1952
jackson:
2053
default-property-inclusion: non_null
21-
22-
profiles:
23-
active: ${SPRING_PROFILES_ACTIVE:dev}
2454

2555
servlet:
2656
multipart:
2757
max-file-size: 10MB
2858
max-request-size: 10MB
2959

60+
# TRACING — Micrometer + OpenTelemetry
61+
management:
62+
tracing:
63+
propagation:
64+
type: w3c
65+
66+
# IMAGE - S3
3067
img:
3168
prefix:
3269
book: book-
3370
maxWidth: 400
3471

72+
# AWS - Credencials
3573
aws:
3674
access-key-id: ${AWS_KEY}
3775
secret-access-key: ${AWS_SECRET}
3876
s3:
3977
bucket: ${BUCKET_NAME:library-api-s3}
4078
region: ${BUCKET_REGION:sa-east-1}
4179

80+
# Resilience4j — CircutBreaker + Retry
4281
resilience4j:
4382
circuitbreaker:
4483
instances:
4584
s3:
4685
sliding-window-size: 5
4786
failure-rate-threshold: 50
4887
wait-duration-in-open-state: 10s
49-
5088
retry:
5189
instances:
5290
s3:

0 commit comments

Comments
 (0)