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

使用 application.properties 中配置的屬性:@Value 註解。app

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

    @RequestMapping(value = "hi")
    public String hello(){
        return "hello world! I am from " + port;
    }
}
相關文章
相關標籤/搜索