答案 0 :(得分:2)
我们可以如下更改aplication.properties
文件的内容
aplication.properties
spring.profiles.active=dev
aplication-dev.properties
#DEV
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql:/localhost:3306/db-dev?useSSL=false
spring.datasource.username=root
spring.datasource.password=root
.......
aplication-qa.properties
#QA
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql:/localhost:3306/db-qa?useSSL=false
spring.datasource.username=root
spring.datasource.password=root
.......
aplication-prod.properties
#PROD
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql:/localhost:3306/db-prod?useSSL=false
spring.datasource.username=root
spring.datasource.password=root
.......
这将解决上述问题