1. <profiles>
    2. <profile>
    3. <id>local</id>
    4. <properties>
    5. <apollo.meta>http://apollo.aibeike.com:8080</apollo.meta>
    6. <apollo.appId>tal-cloud-storage-rest</apollo.appId>
    7. </properties>
    8. </profile>
    9. <profile>
    10. <id>dev</id>
    11. <properties>
    12. <apollo.meta>http://apollo.aibeike.com:8180</apollo.meta>
    13. <apollo.appId>tal-cloud-storage-rest</apollo.appId>
    14. </properties>
    15. <activation>
    16. <activeByDefault>true</activeByDefault>
    17. </activation>
    18. </profile>
    19. <profile>
    20. <id>uat</id>
    21. <properties>
    22. <apollo.meta>http://apollo.aibeike.com:8080</apollo.meta>
    23. <apollo.appId>tal-cloud-storage-rest</apollo.appId>
    24. </properties>
    25. </profile>
    26. <profile>
    27. <id>pro</id>
    28. <properties>
    29. <apollo.meta>http://10.81.34.26:8080,http://10.81.34.219:8080</apollo.meta>
    30. <apollo.appId>jydriverest</apollo.appId>
    31. </properties>
    32. </profile>
    33. </profiles>

    pom.xml 中有以上配置,分别配置了本地、开发、仿真和生产环境的 Apollo 的 metaappid 属性,其中 dev 环境是当前的默认配置,因为 pom.xml 中有 activeByDefault 配置:

    1. <activation>
    2. <activeByDefault>true</activeByDefault>
    3. </activation>

    然后再 application.properties 中可以通过以下方式获取到 pom.xml 的值:

    1. app.id=@apollo.appId@
    2. apollo.meta=@apollo.meta@
    3. apollo.bootstrap.enabled = true
    4. apollo.bootstrap.namespaces = application,cart-config,config,configurationCenter,dc-config,es-config,file-config,paper-config,paperrest-config,queryuserid,slice-config,storage-config,tiku-config,tiku3-config,uc-config,applet-config,oss-config,game-config