user2634876
user2634876

Reputation: 139

Spring Cloud Config Server Issue

I'm currently trying to experiment with Spring Cloud Config and I'm having trouble getting the Spring Cloud Config Server to load properties from my github repository. I've been following the documentation here:

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

Here is my Maven pom.xml file:

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

Here is my Application class:

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); 
    }
}

Here is my application.yml file:

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

server:
  port: 8001

Here is my hello-world-default.yml file that is located at my git repository above:

firstName:John
lastName:Smith

When I run the application, it starts up fine. However, when I access http://localhost:8001/hello-world/default, I get the following response:

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

As you can see, there are no property sources.

Does anyone notice anything wrong with what I've done so far? I've been wrestling with this for a few days now and just can't seem to figure out what's going on. Any help at all would be greatly appreciated.

Thanks, Chris

Upvotes: 1

Views: 2126

Answers (2)

Python Basketball
Python Basketball

Reputation: 2370

i have try your code and get the below response:

 {"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"}}]}

My spring-boot-starter-parent's version is 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>

Maybe you can update your version from 1.0.2.RELEAS to 1.5.8.RELEASE

Upvotes: 0

user2634876
user2634876

Reputation: 139

After some trial and error, I was able to get things to work by specifying "Angel.SR6" as the version of the "spring-cloud-starter-parent" artifact in my Maven pom.xml file.

Chris

Upvotes: 1

Related Questions