1、pom.xml文件加入配置信息
profiles标签与build标签同级
dev dev true prod prod test test
2、resources中创建配置文件
application.properties application-dev.properties application-prod.properties application-test.properties
3、application.properties内容
spring.profiles.active=@profile.active@
4、如果出现mvn打包异常:Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources
解决方法为修改maven-resources-plugin的版本
src/main/resources true application* src/main/resources true application.properties application-${profile.active}.properties org.springframework.boot spring-boot-maven-plugin org.projectlombok lombok org.apache.maven.plugins maven-resources-plugin 3.1.0



