Spring Cloud configuration server ignores configuration properties file

I am trying to create a Windows Spring configuration server that reads configuration data from a properties file, not github. The server starts, but does not execute the properties from the file. I have two configuration files on 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 the error message: "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 am I doing wrong? As I understand it, the name of the properties file must match the server name in order to be recognized by the server.


adding your own profile as spencergibb suggested did not help. my application.properties properties are as follows:

 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 the Spring Cloud Config Server documentation, the configuration server runs on port 8888 by default. In my case, however, if I do not specify a port in my configuration, the server will start at 8080.

There is no parent element and one dependency in the POM file:

  <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-server</artifactId> <version>1.0.0.M2</version> </dependency> </dependencies> 

There is nothing special about the application:

 @Configuration @ComponentScan @EnableAutoConfiguration @EnableConfigServer public class ConfigurationApp { public static void main(String[] args) { SpringApplication.run(ConfigurationApp.class, args); } } 

The configserver.properties file contains one entry: foo = bar

First of all, I always get a startup error

 2014-11-07 09:35:42.852 ERROR 6972 --- [ main] bcPropertySourceBootstrapConfiguration : 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 

No matter what command I execute, I always get 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 answer is always as above

+6
source share
2 answers

By default, the configuration server supports git properties. You will need to configure the native profile with --spring.profiles.active=native so that the configuration server serves the spring environment. spring.config.name for the configuration server is programmatically set to spring.config.name=configserver , so your properties file should be configserver.properties.

+5
source

The endpoint "/ admin / env" on the configuration server serves only the local configuration of the server itself. The server is usually a regular Spring Boot application, so it gets its configuration from "application.properties". If you want to select it from "config-server.properties", you need to install "spring.config.name" or "spring.config.location" (like a regular boot application).

+1
source

Source: https://habr.com/ru/post/977845/


All Articles