独角兽企业重金招聘Python工程师标准>>>
有一些应用,采用了spring boot和spring boot profile。然后想把maven 中的profile和spring boot中的profile 进行一个集成。比如我在idea中修改mvn的profile,就可以修改整个项目的spring boot中的profile。
<profiles><!-- 默认激活 dev 开发环境 --><!-- 线上使用 mvn 打包添加 -Pproduction 变量 --><profile><!-- 本地开发环境 --><id>development</id><properties><profiles.active>development</profiles.active><properties.version>2.0-SNAPSHOT</properties.version></properties></profile><profile><!-- 本地开发环境 --><id>test</id><properties><profiles.active>test</profiles.active><properties.version>test-SNAPSHOT</properties.version></properties><activation><activeByDefault>true</activeByDefault></activation></profile><profile><!-- 生产环境 --><id>production</id><properties><profiles.active>production</profiles.active><properties.version>production-SNAPSHOT</properties.version></properties></profile></profiles>
在yml中使用
spring:profiles:active: @profilesActive@
还有一个很关键的地方需要注意,这样才能替换
<resources><resource><directory>src/main/resources</directory></resource><resource><directory>${basedir}/src/main/resources</directory><filtering>true</filtering><includes><include>**/application.yml</include><include>**/application.yaml</include><include>**/application.properties</include></includes></resource></resources>
Spring boot 使用profile完成不同环境的maven打包功能
springboot maven 多环境配置
Spring Boot Profile 与Maven Profile 集成实践
[Spring Boot 系列] 集成maven和Spring boot的profile功能