修改配置文件适配多环境下的打包配置

main
fzhang5 2025-07-13 20:33:07 +08:00
parent adb0cecca5
commit 00a1a79211
5 changed files with 122 additions and 27 deletions

40
pom.xml
View File

@ -19,6 +19,33 @@
</properties>
<profiles>
<!--开发环境-->
<profile>
<id>dev</id>
<properties>
<profile>dev</profile>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!--测试环境-->
<profile>
<id>test</id>
<properties>
<profile>test</profile>
</properties>
</profile>
<!--生产环境-->
<profile>
<id>prod</id>
<properties>
<profile>prod</profile>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
@ -33,10 +60,19 @@
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<!--指定打包的配置文件且用filtering设置开启过滤-->
<include>application*.yml</include><!--这里使用占位符进行动态引用以确定具体的打包文件-->
<include>application.yml</include><!--主配置文件必须打包-->
</includes>
<filtering>true</filtering><!--开启过滤在打包时application.yml中配置的@env@将被确定到底是什么变量-->
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -0,0 +1,27 @@
server:
port: 9191
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://139.196.201.231:3306/mall?serverTimezone=GMT%2b8&userSSL=false&allowPublicKeyRetrieval=true
username: "myuser"
password: 'Fzhang5.'
servlet:
multipart:
max-file-size: 30MB
redis:
database: 0
host: 139.196.201.231
port: 6379
password: Amk812s$
lettuce:
pool:
min-idle: 0
max-active: 8
max-idle: 8
max-wait: -1ms
connect-timeout: 30000ms
file:
file: /home/fzhang5/file/file/
avatar: /home/fzhang5/file/avatar/

View File

@ -0,0 +1,27 @@
server:
port: 9191
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://139.196.201.231:3306/mall?serverTimezone=GMT%2b8&userSSL=false&allowPublicKeyRetrieval=true
username: "myuser"
password: 'Fzhang5.'
servlet:
multipart:
max-file-size: 30MB
redis:
database: 0
host: 139.196.201.231
port: 6379
password: Amk812s$
lettuce:
pool:
min-idle: 0
max-active: 8
max-idle: 8
max-wait: -1ms
connect-timeout: 30000ms
file:
file: /home/fzhang5/file/file/
avatar: /home/fzhang5/file/avatar/

View File

@ -0,0 +1,27 @@
server:
port: 9191
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://139.196.201.231:3306/mall?serverTimezone=GMT%2b8&userSSL=false&allowPublicKeyRetrieval=true
username: "myuser"
password: 'Fzhang5.'
servlet:
multipart:
max-file-size: 30MB
redis:
database: 0
host: 139.196.201.231
port: 6379
password: Amk812s$
lettuce:
pool:
min-idle: 0
max-active: 8
max-idle: 8
max-wait: -1ms
connect-timeout: 30000ms
file:
file: /home/fzhang5/file/file/
avatar: /home/fzhang5/file/avatar/

View File

@ -1,32 +1,10 @@
server:
port: 9191
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://139.196.201.231:3306/mall?serverTimezone=GMT%2b8&userSSL=false&allowPublicKeyRetrieval=true
username: "myuser"
password: 'Fzhang5.'
servlet:
multipart:
max-file-size: 30MB
redis:
database: 0
host: 139.196.201.231
port: 6379
password: Amk812s$
lettuce:
pool:
min-idle: 0
max-active: 8
max-idle: 8
max-wait: -1ms
connect-timeout: 30000ms
mybatis:
mapper-locations: classpath:mapper/*.xml
configuration:
map-underscore-to-camel-case: true
file:
file: /home/fzhang5/file/file/
avatar: /home/fzhang5/file/avatar/
spring:
profiles:
active: @profile@