当前位置:   article > 正文

springboot项目不同环境打包_${package.environment}

${package.environment}

1、配置文件结构如图

2、修改application.properties

spring.profiles.active= @package.environment@

3、pom.xml配置

  1. <build>
  2. <plugins>
  3. <plugin>
  4. <!-- springboot编译打包插件-->
  5. <groupId>org.springframework.boot</groupId>
  6. <artifactId>spring-boot-maven-plugin</artifactId>
  7. <version>1.5.9.RELEASE</version>
  8. <configuration>
  9. <executable>true</executable>
  10. </configuration>
  11. <executions>
  12. <execution>
  13. <goals>
  14. <goal>repackage</goal>
  15. </goals>
  16. </execution>
  17. </executions>
  18. </plugin>
  19. </plugins>
  20. <resources>
  21. <resource>
  22. <directory>src/main/resources</directory>
  23. <filtering>true</filtering>
  24. <includes>
  25. <include>application.properties</include>
  26. <include>application-${package.environment}.properties</include>
  27. <include>**/*.xml</include>
  28. </includes>
  29. </resource>
  30. </resources>
  31. </build>
  32. <profiles>
  33. <profile>
  34. <id>dev</id>
  35. <properties>
  36. <package.environment>dev</package.environment>
  37. </properties>
  38. <!-- 是否默认,true表示默认,默认加载dev配置文件application-dev.properties-->
  39. <activation>
  40. <activeByDefault>true</activeByDefault>
  41. </activation>
  42. </profile>
  43. <profile>
  44. <id>test</id>
  45. <properties>
  46. <package.environment>test</package.environment>
  47. </properties>
  48. </profile>
  49. <profile>
  50. <!-- 生产环境 -->
  51. <id>prod</id>
  52. <properties>
  53. <package.environment>pro</package.environment>
  54. </properties>
  55. </profile>
  56. </profiles>

4、打包命令

  1. mvn clean package -P dev
  2. mvn clean package -P test
  3. mvn clean package -P pro

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/286350?site
推荐阅读
相关标签
  

闽ICP备14008679号