SpringBoot配置-yml配置与实体类绑定,获取yml中配置的值
1.新建一个springboot项目
2.引入相关依赖
1 <dependencies> 2 <dependency> 3 <groupId>org.springframework.boot</groupId> 4 <artifactId>spring-boot-starter-web</artifactId> 5 </dependency> 6 7 <!--编写测试代码的依赖--> 8 <dependency> 9 <groupId>org.springframework.boot</groupId> 10 <artifactId>spring-boot-starter-test</artifactId> 11 <scope>test</scope> 12 </dependency> 13 14 <!--和yml配置文件绑定所需要的依赖--> 15 <dependency> 16 <groupId>org.springframework.boot</groupId> 17 <artifactId>spring-boot-configuration-processor</artifactId> 18 <optional>true</optional> 19 </dependency> 20 </dependencies>