I've got a @SpringBootApplication
, running with the production
profile, and a spring config server,
{"name":"config-client","profiles":["production"],"label":null,"version":"97611975e6ddb87c7213e18ddbe203ab6ae5485d","state":null,"propertySources":[{"name":"http://git/scm/abm/abm-settings.git/application-production.yml","source":{"my.pretty.property.id":21}}]}
I cannot load property my.pretty.property.id
from server (they are always null), I am using
@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "my.pretty.property")
public class MyProperties {
private String id;
}
and my bootstrap.yml is
spring.cloud:
config:
uri: http://${SERVICE_HOST}/${PROJECT_KEY}-config-server
enabled: false
failFast: true
build.gradle contains this:
"org.springframework.cloud:spring-cloud-starter-consul-all",
"org.springframework.cloud:spring-cloud-consul-core",
"org.springframework.cloud:spring-cloud-starter-hystrix",
"org.springframework.cloud:spring-cloud-starter-hystrix-dashboard",
"org.springframework.cloud:spring-cloud-starter-zipkin",
"org.springframework.cloud:spring-cloud-config-client"
My client application is normally built and deployed, what am I missing?
From Spring Cloud Config:
The HTTP service has resources in the form:
/{application}/{profile}[/{label}]
/{application}-{profile}.yml
/{label}/{application}-{profile}.yml
/{application}-{profile}.properties
/{label}/{application}-{profile}.properties
As you mentioned your application is running under production
profile - hence Spring will try to find file: <cloud-config-server-url>/application-production.yml
and load it, besides application.properties
. But your properties are located in application-integration.yml
and you don't use integration
profile.
So the solution is to use an integration
profile or to create an application-production.yml
on your config. server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With