2016-05-16 105 views
0

我目前正在尝试使用Spring Cloud Config进行实验,并且无法让Spring Cloud Config Server从我的github存储库加载属性。我一直在这里下列文件:Spring Cloud Config服务器问题

http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_spring_cloud_config_server

这里是我的Maven pom.xml文件:

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

    <parent> 
    <groupId>org.springframework.cloud</groupId> 
    <artifactId>spring-cloud-starter-parent</artifactId> 
    <version>1.0.2.RELEASE</version> 
    </parent> 

    <groupId>com.example.spring.cloud</groupId> 
    <artifactId>spring-cloud-test</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <name>Spring Cloud Test</name> 

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

这里是我的应用程序类:

package com.wth.service.config; 

import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication; 
import org.springframework.cloud.config.server.EnableConfigServer; 

@SpringBootApplication 
@EnableConfigServer 
public class Application { 

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

这里是我的application.yml文件:

spring: 
    cloud: 
    config: 
     server: 
     git: 
      uri: https://github.com/crn717/TestRepo.git 

server: 
    port: 8001 

这里是我的问候 - 世界default.yml文件位于上述我的git仓库:

firstName:John 
lastName:Smith 

当我运行应用程序,它启动了罚款。然而,当我访问http://localhost:8001/hello-world/default,我得到如下回应:

{"name":"hello-world","profiles":["default"],"label":"master","propertySources":[]} 

正如你所看到的,有没有财产的来源。

有没有人注意到我到目前为止所做的事情有什么问题?我已经摔了几天,现在似乎无法弄清楚发生了什么。任何帮助都将不胜感激。

谢谢, 克里斯

+0

不要使用'''在应用程序的名称。因为这是用来确定配置文件。 –

回答

1

一些试验和错误之后,我能得到的东西通过指定“Angel.SR6”工作作为版的“春天云起动父”神器我Maven pom.xml文件。

克里斯

0

我有尝试你的代码,并得到响应以下:

{"name":"hello-world","profiles":["default"],"label":null,"version":"68a2c21e35754e0db0dc870dc8126d8e0e8429a0","state":null,"propertySources":[{"name":"https://github.com/crn717/TestRepo.git/hello-world.properties","source":{"firstName":"John"}}]} 

spring-boot-starter-parent的版本是1.5.8.RELEASE,pom.xml中:

<parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.5.8.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>Dalston.SR4</spring-cloud.version> 
</properties> 

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

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

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

也许你可以更新你的版本从1.0.2.RELEAS1.5.8.RELEASE