Spring Boot配置文件

  • SpringBoot会自动识别下面这组配置文件
    application.properties/yml
    config/application.properties/yml
    如果是SpringCloud,还会自动识别下面这组配置文件:
    bootstrap.properties/yml
    config/bootstrap.properties/yml

  • 用@Value来读自定义配置项

  • @Value带默认值写法

 @Value("${test.hello:Spring Boot!}")
 private String testHello;