为了账号安全,请及时绑定邮箱和手机立即绑定

Could not resolve placeholder 'cupszie' in value "cupsize: ${cupszie},age: ${age}"

报错如下:

Error creating bean with name 'helloController': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'cupszie' in value "cupsize: ${cupszie},age: ${age}"


代码如下:

application.yml代码

server:
 port: 8081
 context-path: /girl
cupsize: B
age: 20
content: "cupsize: ${cupszie},age: ${age}"

HelloController.class代码

@RestController
public class HelloController {

   @Value("${cupsize}")
   private String cupsize;

   @Value("${age}")
   private Integer age;

   @Value("${content}")
   private String content;

   @RequestMapping(value = "/hello",method = RequestMethod.GET)
   public String say(){
       return content;
   }
}

代码跟老师的一样,请教老师这是为什么呢

正在回答

12 回答

content: "cupsize: ${cupszie},age: ${age}"这个好像是需要空格吧,很严格,在,后面空格试试

0 回复 有任何疑惑可以回复我~

   @Value("${content}")
   private String content;

改成

 @Value("${server.content}")
   private String content;

11 回复 有任何疑惑可以回复我~
#1

huizai_2014

貌似不行
2017-07-23 回复 有任何疑惑可以回复我~
首页上一页12下一页尾页

举报

0/150
提交
取消
2小时学会Spring Boot
  • 参与学习       151517    人
  • 解答问题       1132    个

Spring Boot入门视频教程,你将学会使用Spring Boot快速构建应用程序

进入课程

Could not resolve placeholder 'cupszie' in value "cupsize: ${cupszie},age: ${age}"

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号