码迷,mamicode.com
首页 > 移动开发 > 详细

使用 application.properties 中配置的属性,举例:@Value("${server.port}")

时间:2019-09-11 11:58:47      阅读:576      评论:0      收藏:0      [点我收藏+]

标签:port   prope   举例   ica   ppi   注解   hello   tco   server   

使用 application.properties 中配置的属性:@Value 注解。

@RestController
public class HelloWorldController {
    @Value("${server.port}")
    String port;

    @RequestMapping(value = "hi")
    public String hello(){
        return "hello world! I am from " + port;
    }
}

使用 application.properties 中配置的属性,举例:@Value("${server.port}")

标签:port   prope   举例   ica   ppi   注解   hello   tco   server   

原文地址:https://www.cnblogs.com/cag2050/p/11505086.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!