Spring Boot Configuration Server问题

时间:2018-10-08 19:01:51

标签: spring-boot

我正在使用此url(https://github.com/Asrit1247/Configuration)从github获取application.properties文件。我的问题是我需要检查是否已加载属性文件。每当我使用http://localhost:1111/application.properties发出请求时,都会收到404错误(请求的页面不存在)。我需要确定此配置服务器是否已成功从gihub加载属性文件。

运行Spring Boot应用程序类时..like

2018-10-08 23:34:18.005  INFO 14960 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}- {profiles}.properties],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String>org.springframework.cloud.config.server.environment.EnvironmentController.properties(java.lang.String,java.lang.String,boolean)throws java.io.IOException
2018-10-08 23:34:18.011  INFO 14960 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}-{profiles}.yml || /{name}-{profiles}.yaml],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> org.springframework.cloud.config.server.environment.EnvironmentController. yaml(java.lang.String,java.lang.String,boolean) throws java.lang.Exception  
2018-10-08 23:34:18.045  INFO 14960 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}/{profiles:.* [^-].*}],methods=[GET]}" onto public org.springframework.cloud.config.environment.Environment org.springframework.cloud.config.server.environment.EnvironmentController .defaultLabel(java.lang.String,java.lang.String)
2018-10-08 23:34:18.049  INFO 14960 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "enter code here{[/{name}/{profiles}/{label:.*}],methods=[GET]}" onto public org.springframework.cloud.config.environment.Environment org.springframework.cloud.config.server.environment.EnvironmentController. labelled(java.lang.String,java.lang.String,java.lang.String)
2018-10-08 23:34:18.051  INFO 14960 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{label}/{name}- {profiles}.yml || /{label}/{name}-{profiles}.yaml],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> org.springframework.cloud.config.server.environment.EnvironmentController .labelledYaml(java.lang.String,java.lang.String,java.lang.String,boolean) throws java.lang.Exception
2018-10-08 23:34:18.054  INFO 14960 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}- {profiles}.json],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> org.springframework.cloud.config.server.environment.EnvironmentController .jsonProperties(java.lang.String,java.lang.String,boolean) throws java.lang.Exception
2018-10-08 23:34:18.059  INFO 14960 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{label}/{name}- {profiles}.properties],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> org.springframework.cloud.config.server.environment.EnvironmentController  .labelledProperties(java.lang.String,java.lang.String,java.lang.String ,boolean) throws java.io.IOException
2018-10-08 23:34:18.063  INFO 14960 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{label}/{name}- {profiles}.json],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> org.springframework.cloud.config.server.environment.EnvironmentController .labelledJsonProperties(java.lang.String,java.lang.String,java.lang.String, boolean) throws java.lang.Exception
2018-10-08 23:34:18.077  INFO 14960 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped " {[/{name}/{profile}/{label}/**],methods=[GET],produces=[application/octet- stream]}" onto public synchronized byte[] org.springframework.cloud.config.server.resource.ResourceController.binary (java.lang.String,java.lang.String,java.lang.String,javax.servlet.http .HttpServletRequest) throws java.io.IOException
2018-10-08 23:34:18.119  INFO 14960 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped " {[/{name}/{profile}/{label}/**],methods=[GET]}" onto public java.lang.String org.springframework.cloud.config.server.resource.ResourceController.retrieve (java.lang.String,java.lang.String,java.lang.String,javax.servlet.http .HttpServletRequest,boolean) throws java.io.IOException
2018-10-08 23:34:18.121  INFO 14960 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped " {[/{name}/{profile}/**],methods=[GET],params=[useDefaultLabel]}" onto public java.lang.String  org.springframework.cloud.config.server.resource.ResourceController .retrieve(java.lang.String,java.lang.String,javax.servlet.http .HttpServletRequest,boolean) throws java.io.IOException

尝试验证为什么会出现这些异常以及如何解决这些错误...请帮助我解决这个问题

下面是我的pom.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://wwww.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.sathya</groupId>
<artifactId>sathyatel-config-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>sathyatel-config-server</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.5.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>Finchley.SR1</spring-cloud.version>
</properties>

<dependencies>

<!--  ACTUATOR -->
  <dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-actuator</artifactId>
  </dependency>

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

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

下面是我的application.properties文件

server.port=1111
spring.cloud.config.server.git.uri=
https://github.com/Asrit1247/Configuration

SathyatelConfigServerApplication.java

package com.sathya.sathyatelconfigserver;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
@SpringBootApplication
@EnableConfigServer
public class SathyatelConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(SathyatelConfigServerApplication.class, args);
  }
}

1 个答案:

答案 0 :(得分:0)

您共享的日志消息不是“ exceptions”,而是一系列具有引发异常的处理程序方法签名的自动配置的端点。这些端点定义为here。还要注意这些消息的INFO日志级别。

此外,在通过调用GET测试配置服务器时,您需要传递配置文件名称。示例:http://localhost:1111/application-default.propertieshttp://localhost:1111/application/default

Spring Cloud Config Documentation