springboot apollo idea启动

1、添加依赖

<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client</artifactId>
<version>1.4.0</version>
</dependency>

2、Apollo创建新项目

3、Apollo不同的环境添加两个公共配置(developer-config //开发公共配置,yunwei-config //运维公共配置)

4、根据代码里面的不同环境对应的不同配置添加到对应环境的Apollo的application上进行发布

启动参数一:
-Dapollo.meta=http://test-apollo-config-service.abc.com:8091/  【获取测试环境的apollo配置】
-Dapollo.bootstrap.enabled=true
-Dapollo.bootstrap.eagerLoad.enabled=true
-Dapp.id=应用名(在apollo上的)
-Dapollo.cluster=default
-Dapollo.bootstrap.namespaces=application,developer-config,yunwei-config
启动参数二:  在idea 里Edit Configurations里VM options 加上启动参数

-Dapp.id=xxx-service -Dapollo.meta=http://test-apollo-config-service.xxx.com:8091 -Dapollo.bootstrap.enabled=true -Dapollo.bootstrap.eagerLoad.enabled=true -Dapollo.cluster=default -Dapollo.logback.enabled=true -Dapollo.bootstrap.namespaces=application,developer-public-config,yunwei-public-config

https://img2023.cnblogs.com/blog/648667/202302/648667-20230222083825122-1959815765.png
https://img2023.cnblogs.com/blog/648667/202302/648667-20230222083825122-1959815765.png

5、带启动参数启动接口的main方法,观察本地C:\opt\data下面有没有生成对应的配置文件(以demo项目为例,会生成C:\opt\data\demo\config-cache\bigdata+default+application.properties文件,观察里面的文件是否对应为此启动程序对应环境下的application配置的文件)

posted @ 2023-02-22 08:50  amu2018  阅读(1190)  评论(0)    收藏  举报