外部配置文件引用
spring.profiles.active用来指定除了当前文件外,其他活动的配置文件。
例如spring.profiles.active=custom
其中custom指application.properties目录下的application-custom.properties
spring.profiles.include用来指定除了当前文件外,还有哪些活动的配置文件。
例如:通过spring.profiles.include=port,mysql
多套配置文件切换
resource目录下的配置文件包括:
- application.properties
- application-custom1.properties
- application-custom2.properties
- application-mysql.properties
- application-port.properties
- application-test-mysql.properties
- application-test-port.properties
application.properties:
#spring.profiles.active=custom1通过切换custom1和2来切换正式和test环境
spring.profiles.active=custom2
application-custom1.properties:
配置该套配置中包含的文件
spring.profiles.include=test-port,test-mysql
application-custom2.properties:
配置该套配置中包含的文件
spring.profiles.include=port,mysql