I have been playing around with the Spring Cloud project on github located here: https://github.com/spring-cloud/spring-cloud-config
However I have been running into some problems getting it to read a local properties file instead of pulling the properties from github. It seems that spring is ignoring the local file even when I remove all the references to github. There is a similar question posted here: Spring-Cloud configuration server ignores configuration properties file
But I haven't seen any good answers yet. I'm wondering if anyone can point me to an example of this? I'd like to set my properties locally instead of using a git repo of any kind. I assume someone has encountered this before, and if there is an example of it somewhere, I'd really like to see it so that I can get moving in the right direction.
Right-click on git-localconfig-repo -> Properties -> copy the Location label address and paste it into the application. properties file. Add the annotation @EnableConfigServer in the SpringCloudConfigServerApplication. java file.
All my code is here https://github.com/spencergibb/communityanswers/tree/so27131143
src/main/java/Application.java
@Configuration
@EnableAutoConfiguration
@EnableConfigServer
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
src/main/resources/application.yml
spring:
application:
name: myconfigserver
profiles:
active: native
my:
property: myvalue
src/main/resources/myapp.yml
my:
otherprop: myotherval
To get the properties for an app named myapp
, do the following.
curl http://localhost:8080/myapp/default
{
"name": "default",
"label": "master",
"propertySources": [
{
"name": "applicationConfig: [classpath:/myapp.yml]",
"source": {
"my.otherprop": "myotherval"
}
},
{
"name": "applicationConfig: [classpath:/application.yml]",
"source": {
"spring.application.name": "myconfigserver",
"spring.profiles.active": "native",
"my.property": "myvalue"
}
}
]
}
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