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

使用 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;
    }
}

posted on 2019-09-11 11:05  cag2050  阅读(2896)  评论(0编辑  收藏  举报

导航