我目前正在嘗試使用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":[]}
正如你所看到的,有沒有財產的來源。
有沒有人注意到我到目前爲止所做的事情有什麼問題?我已經摔了幾天,現在似乎無法弄清楚發生了什麼。任何幫助都將不勝感激。
謝謝, 克里斯
不要使用'''在應用程序的名稱。因爲這是用來確定配置文件。 –