springboot多个application文件
生产部署的配置和测试的配置往往是不一样的,如果都是在一个application.properties文件中修改,不但容易出现遗漏,而且反反复复很是麻烦。如果采用springboot的profiles来区分生产和测试,那么可以减少许多不必要的工作,需要修改的配置往往就是一两句
1、创建生产和测试文件如下:
2、application.properties配置如下:
注:1、spring.profiles.active是用来**springboot多文件配置的;
在springboot中多环境配置文件名需要满足application-xxx.properties的命名规则;
其中的xxx正是我们spring.profiles.active需要指定的配置文件名
2、想使用哪个配置,修改application.properties主配置文件的spring.profiles.active标签
3、加载多个配置文件spring.profiles.active = xxx,xxx
例如:spring.profiles.active = test,database