在SpringBoot中可以把bean的属性放在yaml配置文件中,如下:
cat:
name: tom
age: 12
food:
- fish
- chicken
pom.xml导依赖:
导入configuration-processor
之后,以后在配置文件里写配置时就会有自动提示。这个依赖对业务没有任何影响,只是为了开发方便,所以我们在打jar包的时候应该将其排除,避免最终的jar包里类太多。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org