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;
? ?}
}
代碼跟老師的一樣,請教老師這是為什么呢
2017-06-06
content: "cupsize: ${cupszie},age: ${age}"這個好像是需要空格吧,很嚴格,在,后面空格試試
2017-04-11
? ?@Value("${content}")
? ?private String content;
改成
?@Value("${server.content}")
? ?private String content;