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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
  • 2022-12-23
  • 2021-07-09
  • 2022-12-23
  • 2021-08-07
猜你喜欢
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2023-02-08
  • 2021-10-15
  • 2021-12-04
相关资源
相似解决方案