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

Posted 山水一程

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用 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;
    }
}

以上是关于使用 application.properties 中配置的属性,举例:@Value("${server.port}")的主要内容,如果未能解决你的问题,请参考以下文章