SpringBoot在yml中添加自定义配置并识别

 依赖:

   <!--    配置绑定-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

yml中添加参数配置,注意值前加个空格,不然不试别。

user:
  name: wanli

代码:

@Value("${user.name}")
private String name;
原文地址:https://www.cnblogs.com/wanlige/p/14755865.html