0

I have a Spring Cloud Config Server with multiple profiles and a client. I keep getting the test variable printed for the regular yaml and not the "real" profile. Why is that?

Config Server

import org.springframework.cloud.config.server.EnableConfigServer;

@SpringBootApplication
@EnableConfigServer
public class ConfigserverApplication {

public static void main(String[] args) {
    SpringApplication.run(ConfigserverApplication.class, args);
}
(Application.properties)
spring.cloud.config.server.git.uri=${HOME}/OneDrive/Desktop/Test-Code/repo
server.port=8888
spring.security.user.name=root
spring.security.user.password=123
Config Repo

(application.properties)
test=test

(application-real.properties)- another file
test=real

(application-nonreal.properties)- another file
test=non real
Config Client

package com.jacobs.configclient;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class ConfigclientApplication {
    @Value("{test}")
    private String test;
    public static void main(String[] args) {
        SpringApplication.run(ConfigclientApplication.class, args);
    }

    @GetMapping(value = "/test", produces = MediaType.TEXT_PLAIN_VALUE)
    public String testPhrase() {
        return String.format("Test: " + test);
    }
}
(Application.properties)

spring.application.name = configclient
spring.config.import = optional:configserver:http://localhost:8888
spring.config.profiles.active=real
server.port= 8881

I went to localhost:8881/test and got Test: {test}. I am looking for Test: {real}.

Dlcdoee
  • 1
  • 2

0 Answers0