1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
| # 應用程式配置
spring:
application:
name: side-project
profiles:
active: ${SPRING_PROFILES_ACTIVE:dev}
# 資料庫配置
datasource:
url: jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:side_project}?useSSL=false&serverTimezone=Asia/Taipei&allowPublicKeyRetrieval=true
username: ${DB_USERNAME:root}
password: ${DB_PASSWORD:password}
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
minimum-idle: 5
maximum-pool-size: 20
idle-timeout: 30000
connection-timeout: 30000
max-lifetime: 1800000
pool-name: HikariCP
# JPA 配置
jpa:
hibernate:
ddl-auto: validate
show-sql: false
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL8Dialect
format_sql: true
use_sql_comments: true
jdbc:
batch_size: 25
order_inserts: true
order_updates: true
connection:
provider_disables_autocommit: true
query:
in_clause_parameter_padding: true
cache:
use_second_level_cache: true
use_query_cache: true
region:
factory_class: org.hibernate.cache.jcache.JCacheRegionFactory
# Redis 配置
redis:
host: ${REDIS_HOST:localhost}
port: ${REDIS_PORT:6379}
password: ${REDIS_PASSWORD:}
database: 0
timeout: 10000ms
lettuce:
pool:
max-active: 200
max-idle: 20
min-idle: 5
max-wait: 10000ms
# Cache 配置
cache:
type: redis
redis:
time-to-live: 600000
cache-null-values: false
# Security 配置
security:
oauth2:
client:
registration:
google:
client-id: ${GOOGLE_CLIENT_ID:your-google-client-id}
client-secret: ${GOOGLE_CLIENT_SECRET:your-google-client-secret}
scope: openid,profile,email
# Liquibase 配置
liquibase:
change-log: classpath:db/changelog/db.changelog-master.xml
enabled: true
# Jackson 配置
jackson:
serialization:
write-dates-as-timestamps: false
indent-output: true
deserialization:
fail-on-unknown-properties: false
time-zone: Asia/Taipei
default-property-inclusion: non_null
# 服務器配置
server:
port: ${SERVER_PORT:8080}
servlet:
context-path: /api
compression:
enabled: true
mime-types: text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json
min-response-size: 1024
error:
include-stacktrace: never
include-message: always
# 日誌配置
logging:
level:
root: INFO
com.company.project: DEBUG
org.springframework.security: DEBUG
org.hibernate.SQL: DEBUG
org.hibernate.type.descriptor.sql.BasicBinder: TRACE
pattern:
console: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"
file: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"
file:
name: logs/application.log
logback:
rollingpolicy:
max-file-size: 10MB
max-history: 30
# 管理端點配置
management:
endpoints:
web:
exposure:
include: health,info,metrics,prometheus,liquibase,caches
endpoint:
health:
show-details: always
health:
redis:
enabled: true
db:
enabled: true
metrics:
export:
prometheus:
enabled: true
tags:
application: ${spring.application.name}
environment: ${spring.profiles.active}
# SpringDoc 配置
springdoc:
api-docs:
path: /api-docs
swagger-ui:
path: /swagger-ui.html
operations-sorter: method
tags-sorter: alpha
packages-to-scan: com.company.project.controller
# 應用程式自訂配置
app:
jwt:
secret: ${JWT_SECRET:your-secret-key-must-be-at-least-256-bits}
expiration: ${JWT_EXPIRATION:86400000} # 24 hours
refresh-expiration: ${JWT_REFRESH_EXPIRATION:604800000} # 7 days
cors:
allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:3000,http://localhost:8080}
allowed-methods: ${CORS_ALLOWED_METHODS:GET,POST,PUT,DELETE,OPTIONS}
allowed-headers: ${CORS_ALLOWED_HEADERS:*}
allow-credentials: true
rate-limit:
enabled: true
requests-per-minute: 60
burst-capacity: 100
file-storage:
upload-dir: ${FILE_UPLOAD_DIR:uploads/}
max-file-size: ${MAX_FILE_SIZE:10MB}
allowed-extensions: ${ALLOWED_EXTENSIONS:jpg,jpeg,png,gif,pdf,docx,xlsx}
|
留言討論