这是我所有的代码 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
要获取名为myapp
的应用程序的属性,请执行以下操作。
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"
}
}
]
}
spring.profiles.active=native
运行它吗?(应该适用于1.0.0.M3或快照版本)? - Dave Syer