Ch05 ConfigureProperties
Yang Haoran 8/13/2021 JavaSpring
可以读取properties文件中的配置并进行绑定,prefix中不能有大写字母!!!


测试:

如果在使用第三方类的配置绑定功能,类中没有@Component,那么可以用以下方式:

开启配置绑定功能,并把People注册到容器中

出现如下错误:

在pom.xml中增加如下依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
1
2
3
4
5
2
3
4
5