in Education by
I'm teaching myself the Spring Cloud Config Server and having some trouble with injecting the properties into the bean. So I have a simple Spring Boot Application as config client, just for testing: @SpringBootApplication @ConfigurationProperties public class DemoApplication { @Value("${greeting}") static private String greeting; public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); System.out.println("The greeting is: " + greeting); } } But the system print: The greeting is: null Checking the env endpoint, I actually found the "${greeting}" property was in the environment: profiles: [ ], configService:https://github.com/mstine/config-repo.git/demo.yml: { greeting: "Webhook" }, configService:https://github.com/mstine/config-repo.git/application.yml: { eureka.instance.hostname: "localhost", eureka.instance.leaseRenewalIntervalInSeconds: 10, eureka.instance.metadataMap.instanceId: "${vcap.application.instance_id:${spring.application.name}:${server.port:8080}}", eureka.client.serviceUrl.defaultZone: "${vcap.services.service-registry.credentials.uri:http://127.0.0.1:8761}/eureka/", foo: "barnyardAnimal" }, Notice that in the configService, there is a property called greeting which has value of "Webhook" I'm new to Spring Framework so I'm wondering didn't I mess up something? Someone suggest I can also access external properties using Environment but I didn't find too much tutorial of how to use it. Any thought? ===================================UPDATE====================================== Adding the code of the config server: Application.java: package io.spring.cloud.samples.fortuneteller.configserver; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.config.server.EnableConfigServer; @SpringBootApplication @EnableConfigServer public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } application.yml: server: port: 8888 spring: cloud: config: server: git: uri: https://github.com/mstine/config-repo.git JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
If you are using a local repository, the application.yml should look like this: server: port: 8888 spring: profiles: active: native cloud: config: server: native: searchLocations: file: --Path--

Related questions

0 votes
    I want have a setup of redis where I write to master and read from slave, without any sentinel. I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    I was wondering if I can customize my url into controller to accept null values @RequestMapping( value = " ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 28, 2022 in Education by JackTerrance
0 votes
    The embedded server that starts up with the Spring boot application is ____________. A. Tomcat server B. Weblogic server C. None of the options D. Server has to be configured...
asked Nov 8, 2022 in Education by JackTerrance
0 votes
    Which annoatation is used to inject SessionContext into an ejb?...
asked Nov 7, 2020 in Technology by JackTerrance
0 votes
    Which annoatation is used to inject singleton services like timer service into an ejb?...
asked Nov 7, 2020 in Technology by JackTerrance
0 votes
    Which annoatation is used to inject an datasource into an ejb?...
asked Nov 7, 2020 in Technology by JackTerrance
0 votes
    Which annoatation is used to inject an ejb into another ejb?...
asked Nov 7, 2020 in Technology by JackTerrance
0 votes
    I want to load multiple properties files using tag in a spring 3 application. I searched on the blogs, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 7, 2022 in Education by JackTerrance
0 votes
    I want to load multiple properties files using tag in a spring 3 application. I searched on the blogs, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    How can we override the default properties of Spring boot projects?...
asked Jul 23, 2021 in Technology by JackTerrance
0 votes
    How Do You Override a Spring Boot Project’s Default Properties?...
asked Nov 15, 2020 in Technology by Editorial Staff
0 votes
    I try to setup consul service.but i just can't start it. my project is simple. my email : ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 11, 2022 in Education by JackTerrance
0 votes
    Explain about the spring cloud and spring boot?...
asked Jul 23, 2021 in Technology by JackTerrance
0 votes
0 votes
    I was reading the great article about binding and unbinding events (because I am a js beginner using jQuery ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 9, 2022 in Education by JackTerrance
...