我是使用Spring Cloud Config的新手 .

我有这个配置:

配置

application.yml

server: 
  port: ${PORT:8888}

spring:
  application:
    name: config-server 
  cloud:
    config:
      server:
        git:
          uri: https://github.com/username/SpringCloudConfig
          username: username
          password: password
          timeout: 4

security:
  basic:
    enabled: false
management:
  security:
    enabled: false

POM.xml

<?xml version="1.0" encoding="UTF-8"?>
<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>

    <groupId>com.example</groupId>
    <artifactId>config-server</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

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

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

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

Class

@EnableConfigServer
@SpringBootApplication
public class ConfigServerApplication {

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

当我启动服务器时:http://localhost:8888/health

{“status”:“DOWN”,“diskSpace”:{“status”:“UP”,“total”:494099492864,“free”:440483053568,“threshold”:10485760},“refreshScope”:{“status” : “UP”}, “configServer”:{ “地位”: “DOWN”, “仓库”:{ “应用程序”: “应用程序”, “简介”: “默认”}, “错误”:“java.lang中 . IllegalStateException:无法克隆或签出存储库“}}

我尝试启动它显示的服务:

2018-08-08 13:43:38.270 INFO 32492 --- [main] cccConfigServicePropertySourceLocator:从服务器获取配置:http:// localhost:8888 2018-08-08 13:43:42.884 WARN 32492 --- [main] cccConfigServicePropertySourceLocator:找不到PropertySource:{“timestamp”:1533728622334,“status”:500,“error”:“Internal Server Error”,“exception”:“java.lang.IllegalStateException”,“message”: “无法克隆或签出存储库”路径“:”/ producer-service / default“}”

服务配置

bootstrap.yml

spring:
  application:
    name: producer-service

Class

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

@RestController
class Producer {
    @Value("${message}")
    private String message;

    @Value("${global-message}")
    private String globalMessage;

    @RequestMapping(method = RequestMethod.GET)
    public Map<String, String> message() {
        Map<String, String> response = new HashMap<>();

        response.put("message", message);
        response.put("global-message", globalMessage);

        return response;
    }
}