【问题标题】:Could not locate PropertySource: I/O error on GET request找不到 PropertySource:GET 请求上的 I/O 错误
【发布时间】:2018-07-10 17:42:15
【问题描述】:

我使用start.spring.io 创建了一个简单的新项目intellijSpring Initilizer,并添加了DevTools Acuator Config ClientWeb 作为配置。

这是我的 POM 文件

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>

   <groupId>com.in28minutes.microservices</groupId>
   <artifactId>limits-service</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <packaging>jar</packaging>

   <name>limits-service</name>
   <description>Demo project for Spring Boot</description>

   <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>1.5.10.RELEASE</version>
      <relativePath/> <!-- lookup parent from repository -->
   </parent>

   <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
      <java.version>1.8</java.version>
      <spring-cloud.version>Edgware.SR1</spring-cloud.version>
   </properties>

   <dependencies>
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-actuator</artifactId>
      </dependency>
      <dependency>
         <groupId>org.springframework.cloud</groupId>
         <artifactId>spring-cloud-starter-config</artifactId>
      </dependency>
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-web</artifactId>
      </dependency>

      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-devtools</artifactId>
         <scope>runtime</scope>
      </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>

但是当我运行应用程序时,它会构建,但我收到以下警告。有人知道我做错了什么吗?

Fetching config from server at: http://localhost:8888
2018-01-31 16:41:54.818  WARN 10760 --- [on(2)-127.0.0.1] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/application/default": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect

【问题讨论】:

  • 我认为它与 application.properties 或 application.yml 文件有关.. Spring Boot 应用程序无法为 Cloud config 找到它
  • 我认为这个帖子会对你有所帮助。我认为您面临与此相同的问题:stackoverflow.com/questions/28375416/…
  • 配置服务器是否正在运行?它有某种安全性吗?

标签: java spring maven intellij-idea spring-cloud


【解决方案1】:

在此处查看来自 Dave Syer 的解决方案 (Spring Cloud Config Server Can't locate PropertySource on startup)

如果您的配置服务器也不是配置客户端 您需要设置 spring.cloud.config.enabled=false 以避免该日志 进入(虽然它是无害的)。

【讨论】:

    【解决方案2】:

    当您的一项服务无法连接到云配置服务器时,会显示此错误。

    为了让它工作:

    假设您使用的是 STS 或任何 Eclipse 环境,请运行您的 cloud-config 服务器应用程序,然后运行其配置存储在 cloud-config 中的其他服务。

    保持运行这两个服务非常重要。

    需要注意的其他预防措施有:

    • 您的应用程序的application.properties 文件应重命名为bootstrap.properties
    • 该端口不应被任何其他服务使用

    【讨论】:

      猜你喜欢
      • 2020-01-16
      • 2020-09-20
      • 2019-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多