ellis-L 2016-12-27 09:14 采纳率: 0%
浏览 3713

SpringCloud config 注册服务后client取值问题

将SpringCloud的config部署注册到eureka上的时候遇到如下报错,哪位大神指点一下。谢谢

配置信息:

testConfig-test.properties
from=git-test-1.0

Service :

@EnableConfigServer
@EnableDiscoveryClient
@SpringBootApplication
public class TestSpringCloudConfigApplication {

public static void main(String[] args) {
    SpringApplication.run(TestSpringCloudConfigApplication.class, args);
}

}

application.properties(service)

server.port=7001
spring.application.name=config-server

git管理配置

spring.cloud.config.server.git.uri=xxx/test_spring_cloud_config
spring.cloud.config.server.git.searchPaths=config
spring.cloud.config.server.git.username=xxx
spring.cloud.config.server.git.password=xxx

eureka.client.service-url.defaultZone=http://localhost:7070/eureka/

Client:

@EnableDiscoveryClient
@SpringBootApplication
public class TestSpringCloudConfigClient
{

public static void main(String[] args) {
    new SpringApplicationBuilder(TestSpringCloudConfigClient.class).web(true).run(args);
}

}

@RefreshScope
@RestController
public class TestController
{
@Value("${from}")
private String from;

@RequestMapping("/from")
public String from()
{
    return this.from;
}

public void setFrom(String from)
{
    this.from = from;
}

public String getFrom()
{
    return from;
}

}

报错:

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'from' in string value "${from}"
at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:174) ~[spring-core-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126) ~[spring-core-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:236) ~[spring-core-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:210) ~[spring-core-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer$2.resolveStringValue(PropertySourcesPlaceholderConfigurer.java:172) ~[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:823) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1084) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
... 35 common frames omitted

  • 写回答

1条回答 默认 最新

  • 陈朝晖SHS 2016-12-27 09:34
    关注
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?