当前位置:   article > 正文

springboot多环境配置_springboot include分环境

springboot include分环境

1.配置properties

application.properties中的内容

spring.profiles.active=@profiles.active@

2.配置 pom.xml中配置

  1. <!--配置静态-->
  2. <resources>
  3. <resource>
  4. <directory>src/main/java</directory>
  5. <includes>
  6. <include>**/*.xml</include>
  7. </includes>
  8. </resource>
  9. <resource>
  10. <directory>src/main/resources</directory>
  11. <includes>
  12. <include>**/*.*</include>
  13. </includes>
  14. </resource>
  15. <!--springboot使用的web资源要编译到META-INF/resources-->
  16. <resource>
  17. <directory>src/main/webapp</directory>
  18. <targetPath>META-INF/resources</targetPath>
  19. <includes>
  20. <include>**/*.*</include>
  21. </includes>
  22. </resource>
  23. <!--todo 必须要配置这个,配置的profiles中的参数才会生效-->
  24. <resource>
  25. <directory>src/main/resources/</directory>
  26. <filtering>true</filtering>
  27. </resource>
  28. </resources>
  29. </build>
  30. <!--多环境配置-->
  31. <profiles>
  32. <profile>
  33. <id>dev</id>
  34. <properties>
  35. <profiles.active>dev</profiles.active>
  36. </properties>
  37. <activation>
  38. <activeByDefault>true</activeByDefault>
  39. </activation>
  40. </profile>
  41. <profile>
  42. <id>prod</id>
  43. <properties>
  44. <profiles.active>prod</profiles.active>
  45. </properties>
  46. </profile>
  47. </profiles>

 

3. 打包命令

  1. mvn clean install -Dmaven.test.skip=true -P dev
  2. mvn clean install -Dmaven.test.skip=true -P prod

 

 

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

闽ICP备14008679号