下载完整的springcloud项目,直接启动注册发现服务,报错
报错信息
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:111) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:798) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:104) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.InstanceInfoReplicator 1. r u n ( I n s t a n c e I n f o R e p l i c a t o r . j a v a : 88 ) [ e u r e k a − c l i e n t − 1.6.2. j a r : 1.6.2 ] a t j a v a . u t i l . c o n c u r r e n t . E x e c u t o r s 1.run(InstanceInfoReplicator.java:88) [eureka-client-1.6.2.jar:1.6.2] at java.util.concurrent.Executors 1.run(InstanceInfoReplicator.java:88)[eureka−client−1.6.2.jar:1.6.2]atjava.util.concurrent.ExecutorsRunnableAdapter.call(Executors.java:511) [na:1.8.0_202]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_202]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access 201 ( S c h e d u l e d T h r e a d P o o l E x e c u t o r . j a v a : 180 ) [ n a : 1.8. 0 2 02 ] a t j a v a . u t i l . c o n c u r r e n t . S c h e d u l e d T h r e a d P o o l E x e c u t o r 201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_202] at java.util.concurrent.ScheduledThreadPoolExecutor 201(ScheduledThreadPoolExecutor.java:180)[na:1.8.0202]atjava.util.concurrent.ScheduledThreadPoolExecutorScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_202]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_202]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_202]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_202]
原因
application配置了两个环境的文件,但是idea启动时却没有指定(ps:这里本来是不需要两个文件的)。
解决方法
指定环境——在idea启动器上指定active-profile或直接在yml中配
idea指定环境配置文件:
点击Edit-Configuration
点击ok,再运行即可
yml指定环境配置文件: