springboot會自動去加載application.properties/application.yml中的配置,如果我們需要去切換到其他文件的配置,只需要在application.properties中去設(shè)置。
例如:
現(xiàn)在有一個測試環(huán)境和一個正式環(huán)境,我們現(xiàn)在要將正式環(huán)境切換成測試環(huán)境,一般起名字為application-環(huán)境名.properties
application-test.properties
application.properties
在application.properties中配置spring.profiles.active=test
也可以在yml中配置
spring
profiles
active: test
spring
profiles: test
spring
profiles: dev
用---去分割不同環(huán)境下的配置文件,然后在最頂上配置
spring
profiles
active: test
還可以用命令行去配置,這里省略...
2019-01-07