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
    关注
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?