81,091
社区成员
发帖
与我相关
我的任务
分享
{
"name": "hlhconfig",
"profiles": [
"dev"
],
"label": "master",
"version": "2f9aa5c757cb5c5a18acda41b54ae3b86eb19c1f",
"state": null,
"propertySources": [
{
"name": "https://github.com/hlhdidi/myconfig.git/hlhconfig-dev.properties",
"source": {
"version": "dev",
"photo": "xyy",
"password": "123",
"name": "hlhdidi",
"xx": "mm"
}
}
]
}
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
</dependencies>
spring.cloud.config.uri=http://localhost:8888/
#spring.profiles.active=dev
#spring.cloud.config.profile=dev
#spring.cloud.config.label=master
@SpringBootApplication
@RestController
public class App {
@Value("${photo}")
String password;
public static void main(String[] args) {
SpringApplication.run(App.class,args);
}
@RequestMapping(value = "/hello")
@ResponseBody
public String hi(){
return password;
}
}
2018-09-19 10:29:13.033 INFO 1928 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:8888
2018-09-19 10:29:14.402 INFO 1928 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=application, profiles=[default], label=null, version=2f9aa5c757cb5c5a18acda41b54ae3b86eb19c1f, state=null
2018-09-19 10:29:14.403 INFO 1928 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource [name='configService', propertySources=[MapPropertySource {name='configClient'}]]
2018-09-19 10:29:14.408 INFO 1928 --- [ main] com.zaozuo.client.App : No active profile set, falling back to default profiles: default