spring boot如何使用profiles.active分区配置
1、新建springboot工程不说了,之前的经验都有,新建完成之后如图:

2、一般在resources包下面会看到application.properties这个文件,可以配置数据库的。
如果springboot没有指定任何的配置文件的话,spring boot默认会启动application.properties

3、至于哪个具体的配置文件会被加载,需要在application.properties文件中通过
spring.profiles.active属性来设置,其值对应{profile}值。
如:spring.profiles.active=test就会加载application-test.properties配置文件内容:如图:

4、指定到具体的test配置文件
这时候我们运行的就是test配置文件,如果想要切换的话,直接更改名字就可以了

阅读量:115
阅读量:146
阅读量:114
阅读量:57
阅读量:146