spring云配置客户端(多模块应用程序)无法连接到服务器云配置?

xmq68pz9  于 2021-07-26  发布在  Java
关注(0)|答案(0)|浏览(196)

我有一个基于springboot的微服务,这个微服务里面有一个3模块,所以我有根模块

- root-microservice-app
     - web
       . src
       . pom.xml
     - rest
       . src
       . pom.xml
     - boot-application( which contains the spring boot main class @SpringbootApplication)
       . src
       . pom.xml
 pom.xml

问题是这个 client config 无法连接到 cloud-server-config 另一个独立的spring启动应用程序。我完成了在客户机中设置bootstap.yml的所有步骤,并提供了服务器配置服务id,因为它将由eureka发现,还添加了客户机pom中的客户机配置依赖项。
infos:我所有的微服务都会运行到docker中,所以通常当客户端启动并正常运行时,它可以找到服务器配置,但不幸的是它看不到它。
有人知道这个问题吗。
编辑:我在构建应用程序时遇到此错误

ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/application/default": Connection r efused: connect; nested exception is java.net.ConnectException: Connection refused: connect

问:我应该把客户机依赖关系放在父pom或引导应用程序pom(其中包含bootstrap.yml文件)的什么位置。当做
引导.yml:

spring:
  application:
    name: my-app
  cloud:
    config:
      discovery:
        enabled: true
        service-id: CONFIG-SERVER
      clone-on-start: true
      failFast: true
      retry:
        max-interval: 5000
        max-attempts: 50
      username: usr
      password: pswd

以下是客户端依赖项:

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-aop -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
            <version>${version.spring.cloud.starter.aop}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework.retry/spring-retry -->
        <dependency>
            <groupId>org.springframework.retry</groupId>
            <artifactId>spring-retry</artifactId>
            <version>${version.spring.cloud.retry}</version>
        </dependency>
        <!-- SPRING CLOUD CONFIG SERVER CLIENT -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-client</artifactId>
            <version>2.1.0.RELEASE</version>
        </dependency>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题