1

I am having trouble fetching the properties form a spring config server with another spring application.

I can fetch it with the browser so the config server itself seems to be fine, my client application however seems to just ignore my configuration where it should fetch the properties.

The Config server is straight forward:

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

and the application.properties

server.port=8888
spring.profiles.active=native
spring.cloud.config.server.native.searchLocations=${HOME}/FH/SKS/configserver/src/main/resources/configuration
management.security.enabled=false

I dont want to use any git for now so i just use a local file which is called

newsservice-config.properties:

message=Hello configuration server !

I can get the properties just fine with a browser:

enter image description here

.. so i guess its in my other configuration!

The Client

First of all i use an application.yml for general configuration which looks like this:

server:
  port : 8081

spring:
  jpa:
    generate-ddl: true
    hibernate:
      ddl-auto: create
    show-sql: true
    databasePlatform: org.hibernate.dialect.MySQL5Dialect

not much in there regarding the config server. I have created a bootstrap.properties file besides the application.yml for the config server configuration:

spring.application.name=newsservice-config
spring.cloud.config.server.uri=http://localhost:8888
management.security.enabled=false

Name is correct.(name of the configuration file on the config server) Server adress is correct.

The REST Controller where i want to test everything:

@RefreshScope
@RestController
@RequestMapping("/article")
@CrossOrigin
public class ArticleController {
    @Value("${message: Default Hello}")
    private String message;

    @GetMapping("/test")
    public String tester(){
        return this.message;
    }
}

..however it doesnt fetch anything from the config server....

enter image description here

The resource structure of my client:

enter image description here

Any ideas what i am doing wrong ?

Kind regards...

MajesticOl
  • 311
  • 1
  • 20

1 Answers1

1

It seems that its about the version of the config client implementation. it works if i use this in my pom.xml file

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.6.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

..however the newer version will not work

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

I am really confused why this is the case. Also i have recognized that depending on the implementations, the config server seems to be able to handle a normal request of the configuration through the browser or not...

Behavior and compatability also seems to depend on this section of the pom.xml

<properties>
        <java.version>15</java.version>
        <spring-cloud.version>2020.0.0-RC1</spring-cloud.version>
    </properties>

or

<properties>
        <java.version>15</java.version>
        <spring-cloud.version>Hoxton.SR9</spring-cloud.version>
    </properties>

Sometimes one of thise two options is working with both spring boot parent versions... sometimes not.

My conclusion is that this is ultra confusing and i just have to roll with whatever works i guess without asking too many questions.... :(

MajesticOl
  • 311
  • 1
  • 20