1. application.properties 中添加值
myHeight=200
myInfo=myHeight:${myHeight}
2. controller中注入该值,并在方法中输出
@RestController
public class HelloController {
@Value("${myHeight}")
private Integer myHeight;
@Value("${myInfo}")
private String myInfo;
@RequestMapping(value = "/getValue", method = RequestMethod.GET)
public String hello() {
return myInfo + ",height:"+myHeight;
}
}
3. 打开浏览器访问