首页 > 技术文章 > 使用 application.properties 中配置的属性,举例:@Value("${server.port}")

cag2050 2019-09-11 11:05 原文

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

推荐阅读