2016-05-16 94 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

相關問題