Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
145 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...