I am trying to create a Spring Cloud configuration server which reads the configuration data from the properties file and not a github. The server starts, but does not serve the properties from the file. I have two configuration files on the classpapath:
bootstrap.yml
spring:
application:
name: config-server
config-server.properties
foo=bar
when I go to the url which supposedly should give me the value of the foo property:
curl http://localhost:8888/admin/env/foo
I get an error: "timestamp":1415298615005,"status":404,"error":"Not Found","exception":"org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint$NoSuchPropertyException","message":"No such property: foo","path":"/admin/env/foo"}
I am wondering what I am doing wrong? As far as I understand the properties file name should match the server name in order to be recognized by the server.
adding native profile as spencergibb suggested did not help. my application.properties looks like:
server.port=8888
spring.profiles.active=native
spring.config.name=configserver
spring.application.name=configserver
Note, that I had to specify the server port. According to Spring Cloud Config Server documentation the configuration server starts on port 8888 by default. In my case however unless I specify the port in my config the server starts at 8080.
The POM file has no parent and a single dependency:
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
<version>1.0.0.M2</version>
</dependency>
</dependencies>
The application has nothing special in it:
@Configuration
@ComponentScan
@EnableAutoConfiguration
@EnableConfigServer
public class ConfigurationApp {
public static void main(String[] args) {
SpringApplication.run(ConfigurationApp.class, args);
}
}
The configserver.properties file contains a single entry: foo=bar
First of all I am always getting a startup error
2014-11-07 09:35:42.852 ERROR 6972 --- [ main] b.c.PropertySourceBootstrapConfiguration : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/configserver/default/master":Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
Regardless of which command I execute I am always getting the same response from the server:
{"name":"info","label":"master","propertySources":[{"name":"bootstrap","source":{}},{"name":"applicationConfig: [classpath:/application.properties]","source":{"spring.config.name":"configserver","spring.application.name":"configserver","server.port":"8888","spring.profiles.active":"native"}},{"name":"defaultProperties","source":{"spring.application.name":"bootstrap"}}]}
I tried:
http://localhost:8888/configserver/env
http://localhost:8888/configserver/env/foo
http://localhost:8888/configserver/info
http://localhost:8888/configserver/beans
http://localhost:8888/configserver/health
The response is always as above
Overriding the Values of Remote Properties If you want to allow your applications to override the remote properties with their own System properties or config files, the remote property source has to grant it permission by setting spring. cloud. config.
By default, the config server serves properties from git. You will need to set the profile to native
using --spring.profiles.active=native
for the configserver to serve the spring environment. The spring.config.name
for the config server is programmatically set to spring.config.name=configserver
so your properties file will need to be configserver.properties.
The "/admin/env" endpoint in a config server only serves the local configuration of the server itself. The server is usually just a regular Spring Boot app, so it gets its configuration from "application.properties". If you want to pick it up from "config-server.properties" you need to set "spring.config.name" or "spring.config.location" (just like a normal Boot app).
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