当前位置:   article > 正文

springboot 区分环境配置_: @package.environment@ 不识别

: @package.environment@ 不识别

1、yml 文件:'@package.environment@'

or  properties : @package.environment@

2、pom.xml 

  1. <profiles>
  2. <!--开发环境-->
  3. <profile>
  4. <id>dev</id>
  5. <properties>
  6. <package.environment>dev</package.environment>
  7. </properties>
  8. <activation>
  9. <activeByDefault>true</activeByDefault>
  10. </activation>
  11. </profile>
  12. <!--测试环境-->
  13. <profile>
  14. <id>test</id>
  15. <properties>
  16. <package.environment>test</package.environment>
  17. </properties>
  18. <activation>
  19. <activeByDefault>false</activeByDefault>
  20. </activation>
  21. </profile>
  22. <!--生产环境-->
  23. <profile>
  24. <id>prod</id>
  25. <properties>
  26. <package.environment>prod</package.environment>
  27. </properties>
  28. <activation>
  29. <activeByDefault>false</activeByDefault>
  30. </activation>
  31. </profile>
  32. </profiles>
  33. <build>
  34. <finalName>xxx</finalName>
  35. <resources>
  36. <resource>
  37. <directory>src/main/resources</directory>
  38. </resource>
  39. <resource>
  40. <directory>src/main/java</directory>
  41. <includes>
  42. <include>**/*.xml</include>
  43. </includes>
  44. </resource>
  45. <resource>
  46. <directory>src/main/resources</directory>
  47. <!-- 是否替换@xx@表示的maven properties属性值 -->
  48. <filtering>true</filtering>
  49. <includes>
  50. <include>application.properties</include>
  51. <include>application-${package.environment}.properties</include>
  52. </includes>
  53. </resource>
  54. </resources>
  55. <plugins>
  56. <plugin>
  57. <groupId>org.springframework.boot</groupId>
  58. <artifactId>spring-boot-maven-plugin</artifactId>
  59. </plugin>
  60. </plugins>
  61. </build>

 开发工具:idea 

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

闽ICP备14008679号