服务器:centos7
apollo:1.7
开发环境:springboot2.3
1.整合
| 1 2 3 4 5 6 7 8 9 10 | <dependency>     <groupId>com.ctrip.framework.apollo</groupId>     <artifactId>apollo-client</artifactId>     <version>1.7.0</version> </dependency> <dependency>     <groupId>org.apache.commons</groupId>     <artifactId>commons-lang3</artifactId>     <version>3.10</version> </dependency> | 
| 1 2 3 4 | app.id=dev apollo.meta=http://192.167.2.123:8080 #eureka地址 apollo.bootstrap.enable=true apollo.bootstrap.namespaces=application | 
| 1 2 3 4 | @SpringBootApplication @EnableApolloConfig public class ApolloServerApplication { } | 
2.启动时异常
| 1 2 3 4 5 6 7 8 | Load config failed, will retry in 1 SECONDS. appId: dev, cluster: default, namespaces: application 2021-02-01 19:02:30.617  WARN 42252 --- [           main] c.c.f.a.i.AbstractConfigRepository       : Sync config failed, will retry. Repository class com.ctrip.framework.apollo.internals.RemoteConfigRepository, reason: Load Apollo Config failed - appId: dev, cluster: default, namespace: application, url: http://192.168.1.26:8080/configs/dev/default/application?ip=192.168.1.2 [Cause: Could not complete get operation [Cause: connect timed out]] 2021-02-01 19:02:31.623  WARN 42252 --- [           main] c.c.f.a.i.RemoteConfigRepository         : Load config failed, will retry in 1 SECONDS. appId: dev, cluster: default, namespaces: application 2021-02-01 19:02:33.624  WARN 42252 --- [           main] c.c.f.a.i.LocalFileConfigRepository      : Sync config from upstream repository class com.ctrip.framework.apollo.internals.RemoteConfigRepository failed, reason: Load Apollo Config failed - appId: dev, cluster: default, namespace: application, url: http://192.168.1.26:8080/configs/dev/default/application?ip=192.168.1.2 [Cause: Could not complete get operation [Cause: connect timed out]] 2021-02-01 19:02:33.628  WARN 42252 --- [ngPollService-1] c.c.f.a.i.RemoteConfigLongPollService    : Long polling failed, will retry in 1 seconds. appId: dev, cluster: default, namespaces: application, long polling url: http://192.168.1.26:8080/notifications/v2?cluster=default&appId=dev&ip=192.168.1.2¬ifications=%5B%7B%22namespaceName%22%3A%22application%22%2C%22notificationId%22%3A-1%7D%5D, reason: Could not complete get operation [Cause: connect timed out] 2021-02-01 19:02:34.625  WARN 42252 --- [           main] c.c.f.a.i.RemoteConfigRepository         : Load config failed, will retry in 1 SECONDS. appId: dev, cluster: default, namespaces: application 2021-02-01 19:02:35.629  WARN 42252 --- [ngPollService-1] c.c.f.a.i.RemoteConfigLongPollService    : Long polling failed, will retry in 2 seconds. appId: dev, cluster: default, namespaces: application, long polling url: http://192.168.1.26:8080/notifications/v2?cluster=default&appId=dev&ip=192.168.1.2¬ifications=%5B%7B%22namespaceName%22%3A%22application%22%2C%22notificationId%22%3A-1%7D%5D, reason: Could not complete get operation [Cause: connect timed out] 2021-02-01 19:02:36.625  WARN 42252 --- [           main] c.c.f.a.i.LocalFileConfigRepository      : Sync config from upstream repository class com.ctrip.framework.apollo.internals.RemoteConfigRepository failed, reason: Load Apollo Config failed - appId: dev, cluster: default, namespace: application, url: http://192.168.1.26:8080/configs/dev/default/application?ip=192.168.1.2 [Cause: Could not complete get operation [Cause: connect timed out]] | 
3.分析原因
http://192.168.1.26:8080 这个地址不是我eureka的地址,所以才找的时候会找不到
4.解决办法
启动的环境变量中加入: -Dapollo.configService=http://192.167.2.123:8080
将地址改为eureka的地址就好
————————————————
版权声明:本文为CSDN博主「weixin_38777065」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_38777065/article/details/113527235