求教,初学springcloud-config,客户端接受不到服务端拉取的参数

dahulong 2018-09-19 10:31:59
客户端和服务端的配置都和官网一样,服务端配置好后,访问http://localhost:8888/hlhconfig/dev/master,得到JSON返回字符串,
{
"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"
}
}
]
}

客户端pom如下:
<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>

客户端application.properties如下:
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


基本都是按照官网来的,但是就是没有数据,求大神指教
...全文
265 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
dahulong 2018-09-20
  • 打赏
  • 举报
回复
已经解决了,我没有填写application.name参数,谢谢大家
dahulong 2018-09-19
  • 打赏
  • 举报
回复
引用 1 楼 getdate 的回复:
你的springboot 是什么版本啊?
springboot:1.5.10.RELEASE,springcloudconfig:1.4.4.RELEASE,spring-cloud-dependencies:Edgware.SR2
dahulong 2018-09-19
  • 打赏
  • 举报
回复
springboot:1.5.10.RELEASE,springcloudconfig:1.4.4.RELEASE,spring-cloud-dependencies:Edgware.SR2
getdate 2018-09-19
  • 打赏
  • 举报
回复
你的springboot 是什么版本啊?

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧