1

My Spring Cloud config client is not able to resolve the server1 property. It is throwing "Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'server1' in value "${server1}""

@Controller
@RefreshScope
public class OSLController {
    @Value("${server1}")
    public String oslServer; 
}

Here is the bootstrap.properties of the config client:

spring.cloud.config.uri=http://localhost:8888
spring.profiles.active=preprod
spring.application.name=osl

Here are the configurations of the config server: application.properties

server.port=8888
spring.profiles.active=native
spring.cloud.config.server.native.searchLocations=classpath:/config/osl,classpath:/osl,classpath:/config

Here are the paths when hit by the browser: http://localhost:8888/osl/preprod

{
  "name": "osl",
  "profiles": [
    "preprod"
  ],
  "label": null,
  "version": null,
  "state": null,
  "propertySources": [
    {
      "name": "class path resource [config/osl/osl-preprod.properties",
      "source": {
        "server1": "preprod"
      }
    },
    {
      "name": "class path resource [config/osl/osl.properties",
      "source": {
        "server1": "common"
      }
    }
  ]
}

When the config client is started, it prints the following logs:


2021-02-27 19:19:06.576  INFO 27040 --- [           main] in.rahul.ConfigClient2Application        : Starting ConfigClient2Application using Java 15.0.1 on DESKTOP-CJ4TSGP with PID 27040 (C:\Rahul\Workspace\ConfigClient-2\target\classes started by Rahul in C:\Rahul\Workspace\ConfigClient-2)
2021-02-27 19:19:06.579  INFO 27040 --- [           main] in.rahul.ConfigClient2Application        : No active profile set, falling back to default profiles: default
2021-02-27 19:19:07.282  INFO 27040 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=d5ff5a52-737f-3fd5-8528-04cdeb4cd847
2021-02-27 19:19:07.475  INFO 27040 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)

The tutorial that I am following prints the following as well while starting the config client

Fetching config from server at: http://localhost:8888/

The above message is not coming in my config client which is leading me to believe that config client is not able to recognize the config server.

Can someone please guide the problem and how to troubleshoot this? If I am able to read the configs from browser why the client is not able to connect and resolve the server1 property.

I am using windows machine.

Thanks.

Rahul
  • 21
  • 3

0 Answers0