org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientStartUp': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'guestname' in value "${guestname}"
为什么同样的代码,我的就是这个结果呢?哭晕
我的bootstrap.yml文件也加载不到,最后我在client里,添加了如下依赖,启动正常。
<!-- SpringCloud Config Client --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-client</artifactId> <version>2.0.0.RELEASE</version> </dependency>
我的Cloud版本是:Finchley.RELEASE。
<!-- SpringCloud Config Server --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-server</artifactId> <version>2.0.0.RELEASE</version> </dependency>
其他配置信息:
springboot 版本
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RELEASE</version> <relativePath /> <!-- lookup parent from repository --> </parent>
springcloud版本
<!-- SpringCloud使用Finchley版本 --> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Finchley.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
spring cloud config
<!-- Spring Cloud Start Config --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> <version>2.0.0.RELEASE</version> </dependency>
大佬,后面怎么解决的,我也是这个问题
server 和client 都要启动。
我在client-dev.ym文件中guestname:的后面有一个空格就可以了
guestname: xiaowang
@Value("${guestname:default_name}")