【发布时间】:2016-09-12 18:43:50
【问题描述】:
我目前正在尝试使用 Spring Cloud Config,但无法让 Spring Cloud Config Server 从我的 github 存储库加载属性。我一直在关注这里的文档:
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
这是我的 hello-world-default.yml 文件,位于我上面的 git 存储库中:
firstName:John
lastName:Smith
当我运行应用程序时,它可以正常启动。但是,当我访问http://localhost:8001/hello-world/default 时,我得到以下响应:
{"name":"hello-world","profiles":["default"],"label":"master","propertySources":[]}
如您所见,没有属性来源。
到目前为止,有人注意到我所做的事情有什么问题吗?我已经为此挣扎了几天,似乎无法弄清楚发生了什么。任何帮助都将不胜感激。
谢谢, 克里斯
【问题讨论】:
-
不要在应用程序名称中使用
-。因为它用于确定配置文件。
标签: spring spring-boot