当前位置: 首页 > 知识库问答 >
问题:

获取错误:java.lang.IllegalStateException:未找到configserver(config-server)的实例

松茂实
2023-03-14
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/
spring:
  application:
    name: eureka-server

server:
  port: 1111

eureka:
  client:
    registerWithEureka: false
    fetchRegistry: false
    service-url:
      defaultZone: http://localhost:1111/eureka/
spring:
  application:
    name: eureka-client
  cloud:
    config:
      discovery:
        enabled: true
        service-id: config-server

eureka:
  client:
    service-url:
      defaultZone: http://localhost:1111/eureka/

server:
  port: 8081

config服务器本身的工作方式是,当运行时,它为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文件:

ConfigServerApplication:

@SpringBootApplication
@EnableDiscoveryClient
@EnableConfigServer
public class ConfigServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(ConfigServerApplication.class, args);
    }

}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.8.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.danielturato</groupId>
    <artifactId>config-server</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>config-server</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <spring-cloud.version>Greenwich.SR2</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-server</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-netflix-eureka-client</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
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

我得出的结论是,要么是我的项目文件出了问题,要么是我的电脑出了问题,因为我在笔记本电脑上完成了一个相同的项目,项目运行完全正常。我也不知道出了什么问题

共有1个答案

子车英达
2023-03-14

我的设置也有同样的问题。

我将spring.application.name:config-server...更改为spring.application.name:configserver

事情就这样不了了之了。我知道这是一个奇怪的,但它为我做了工作。

 类似资料:
  • 问题内容: 请指出我缺少的一点: openSUSE 11.3 编辑: 问题答案: 你需要的包报头和共享库链接, 开发 除了正常的包 部署 。就发行版而言,有两种不同的用例。 在我的分布中: 并提供了CRAN的所有构建时检查功能,可以按预期从CRAN程序包中正常工作。 2016年末更新: 正如@ JoshO’Brien在评论中指出 较小更新:在2016年运行Ubuntu 14.04.2的这里似乎已被

  • 你好,我试图学习野蝇和springboose一个非常简单的应用程序使用eclipse。项目名称是springboo-test。包括主方法类在内的所有类都在同一个包中。 主方法类称为'App',其代码如下: 以下是服务器日志: 11:36:57281信息[org.wildfly.extension.undertow](服务器服务线程池--68)WFLYUT0021:注册的web上下文:'/sprin

  • 我在Laravel应用程序中工作,并通过列将表格与表格关联。我在表中已经有列。但当我运行命令时,我得到一个错误: `SQLSTATE[42S22]:未找到列:“字段列表”中的1054未知列“用户id” 获取以下错误:

  • 我正在使用Eclipse IDE 2020-03版本和Java。我正在尝试使用FXML,在线查看了一些教程和步骤,并按照它们进行了操作。但我仍然得到以下错误: 启动层初始化过程中发生错误java.lang.module.FindExcture:找不到模块javafx.controls 我谷歌了一下寻求帮助。有很多人有同样的问题,并且能够解决这个问题。但是我所看到的是他们正在使用NetBeans I

  • 我一直试图在2.1.0版本中运行Spring引导。我得到404错误,即使试图访问localhost:8080。我已经修改了所有的控制器,服务在同一个主包,但没有运气。任何帮助都很感激。下面是我的控制台日志...甚至localhost:8080也不起作用。 控制器类:

  • 我收到了以下错误消息: 致命错误:未捕获错误:在F:\projects\websites\main\u website\app\Exceptions\Handler中找不到类“Auth”。php:65堆栈跟踪:#0 F:\projects\websites\main\u website\vendor\laravel\framework\src\illighted\Foundation\Http\K