0

目前我正在Spring引导微服务项目中工作。考虑我有3个名为A,B,C的微服务。现在我的项目为每个微服务分别提供了application.yml文件。现在我想添加一个微服务D,用于管理所有服务属性文件。在Spring Boot中管理普通微服务中的属性文件

查看我的配置服务结构

enter image description here

eureka.yml(内部配置服务)文件是:

server: 
    port: 8761 
eureka: 
    client: 
    registerWithEureka: false 
    fetchRegistry: false 
    server: 
    waitTimeInMsWhenSyncEmpty: 0 
endpoints: 
    sensitive: false 

尤里卡服务bootstrap.properties是:

spring: 
    application: 
    name: eureka 
    cloud: 
    config: 
     uri: http://localhost:8888 

配置服务应用程序属性:

spring: 
    application: 
    name: config 
    cloud: 
    config: 
     server: 
     native: 
      search-locations: classpath:/config/DEVELOP 
    profiles: 
    active: native 

server: 
    port: 8888 

我的配置应用程序文件是:

@SpringBootApplication 
@EnableConfigServer 
public class ConfigApplication { 

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

我做了如下步骤:

  1. 启动配置服务
  2. 启动尤里卡服务

不幸的是,尤里卡服务r出现错误。

com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server 

问题是运行尤里卡服务器,同时,其不看配置文件是配置服务里面......

帮我解决这个问题。或者,而不是微服务,我怎么能去文件夹?

+0

您确定Eureka从配置服务中获取其属性吗?通常情况下,您应该在日志中看到类似这样的内容:[[ConfigServicePropertySourceLocator.java:80] - 从服务器获取配置:http:// localhost:8888'。除此之外,请确保您的配置实际上可用。您可以通过访问http:// localhost:8888/eureka来查看您在Eureka中获得的配置。 – g00glen00b

回答

0

感谢@ g00glen00b

我改变配置的服务引导阳明如下:

spring: 
    application: 
    name: config 
    cloud: 
    config: 
     server: 
     native: 
      searchLocations: classpath:/config/DEVELOP/ 
    profiles: 
    active: native 

server: 
    port: 8888 

其工作的罚款。

相关问题