我正在尝试向我的 eureka 发现服务器注册一个 spring-cloud 配置服务器,但是我遇到了这个错误:
java.lang.IllegalStateException:找不到配置服务器(配置服务器)的实例
application.yml(配置服务器):
spring:
application:
name: config-server
cloud:
config:
server:
git:
uri: https://github.com/danielturato/microservices-config.git
username: *******
password: *******
clone-on-start: true
server:
port: 8888
eureka:
instance:
hostname: localhost
appname: config-server
client:
service-url:
defaultZone: http://localhost:1111/eureka/
bootstrap.yml(尤里卡服务器):
spring:
application:
name: eureka-server
server:
port: 1111
eureka:
client:
registerWithEureka: false
fetchRegistry: false
service-url:
defaultZone: http://localhost:1111/eureka/
bootstrap.yml(尤里卡客户端):
spring:
application:
name: eureka-client
cloud:
config:
discovery:
enabled: true
service-id: config-server
eureka-client.yml(在配置服务器 repo 上找到的 eureka-client 配置):
eureka:
client:
service-url:
defaultZone: http://localhost:1111/eureka/
server:
port: 8081
配置服务器本身在运行时工作,它为 eureka 客户端获取配置。 但是,每隔几分钟我就会收到此错误,并且配置服务器本身从未注册:
java.lang.IllegalStateException: No instances found of configserver (config-server)
at org.springframework.cloud.config.client.ConfigServerInstanceProvider.getConfigServerInstances(ConfigServerInstanceProvider.java:48) ~[spring-cloud-config-client-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.cloud.config.client.DiscoveryClientConfigServiceBootstrapConfiguration.refresh(DiscoveryClientConfigServiceBootstrapConfiguration.java:101) [spring-cloud-config-client-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.cloud.config.client.DiscoveryClientConfigServiceBootstrapConfiguration.heartbeat(DiscoveryClientConfigServiceBootstrapConfiguration.java:92) [spring-cloud-config-client-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.cloud.config.client.DiscoveryClientConfigServiceBootstrapConfiguration.onApplicationEvent(DiscoveryClientConfigServiceBootstrapConfiguration.java:82) [spring-cloud-config-client-2.1.3.RELEASE.jar:2.1.3.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) [spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) [spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) [spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402) [spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:408) [spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359) [spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.cloud.netflix.eureka.CloudEurekaClient.onCacheRefreshed(CloudEurekaClient.java:123) [spring-cloud-netflix-eureka-client-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at com.netflix.discovery.DiscoveryClient.fetchRegistry(DiscoveryClient.java:999) [eureka-client-1.9.12.jar:1.9.12]
at com.netflix.discovery.DiscoveryClient.refreshRegistry(DiscoveryClient.java:1497) [eureka-client-1.9.12.jar:1.9.12]
at com.netflix.discovery.DiscoveryClient$CacheRefreshThread.run(DiscoveryClient.java:1464) [eureka-client-1.9.12.jar:1.9.12]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_211]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_211]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_211]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_211]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_211]
从这个错误来看,我可能错了,但我觉得配置服务器有问题,但我真的不确定出了什么问题。 请参阅上面的 application.yml 文件,并参阅下面的 Application 类和 pom 文件:
配置服务器应用程序:
@SpringBootApplication
@EnableDiscoveryClient
@EnableConfigServer
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}
ConfigServer 的 pom.xml:
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.1.8.RELEASE
com.danielturato
config-server
0.0.1-SNAPSHOT
config-server
Demo project for Spring Boot
1.8
Greenwich.SR2
org.springframework.cloud
spring-cloud-config-server
org.springframework.cloud
spring-cloud-netflix-eureka-client
org.springframework.boot
spring-boot-starter-test
test
org.springframework.cloud
spring-cloud-dependencies
${spring-cloud.version}
pom
import
org.springframework.boot
spring-boot-maven-plugin
配置服务器日志:
2019-09-12 17:14:25.311 INFO 1656 --- [ main] c.d.c.ConfigServerApplication : No active profile set, falling back to default profiles: default
2019-09-12 17:14:25.983 INFO 1656 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=5638ff1e-e195-3b5c-a934-c721843f315c
2019-09-12 17:14:26.042 INFO 1656 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$3fdd8981] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-12 17:14:26.219 INFO 1656 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8888 (http)
2019-09-12 17:14:26.237 INFO 1656 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-09-12 17:14:26.238 INFO 1656 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.24]
2019-09-12 17:14:26.340 INFO 1656 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-09-12 17:14:26.340 INFO 1656 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1019 ms
2019-09-12 17:14:28.719 INFO 1656 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-09-12 17:14:29.162 INFO 1656 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2019-09-12 17:14:29.245 INFO 1656 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8888 (http) with context path ''
2019-09-12 17:14:29.247 INFO 1656 --- [ main] c.d.c.ConfigServerApplication : Started ConfigServerApplication in 5.097 seconds (JVM running for 6.359)
2019-09-12 17:14:47.055 INFO 1656 --- [nio-8888-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-09-12 17:14:47.055 INFO 1656 --- [nio-8888-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2019-09-12 17:14:47.061 INFO 1656 --- [nio-8888-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 6 ms
2019-09-12 17:14:47.769 INFO 1656 --- [nio-8888-exec-1] o.s.c.c.s.e.NativeEnvironmentRepository : Adding property source: file:/C:/Users/danie/AppData/Local/Temp/config-repo-6536884673987435552/eureka-client.yml
如果有人知道我做错了什么,任何帮助都会很棒。 谢谢。
结论
我得出的结论是,我的项目文件或计算机有问题,因为我在笔记本电脑上完成了一个相同的项目,并且该项目完全正常运行。 我仍然不知道出了什么问题