first step
Import the annotated jar package
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</dependency>
Second step
Use annotations in entity classes
@ToString
@Data
@AllArgsConstructor
@NoArgsConstructor
@Configuration
@ConfigurationProperties(prefix = "haidong")
public class dog {
private Integer id;
private String name;
private String pwd;
private Integer age;
}
third step
Write the value to the attribute in the yml file
haidong:
id: 1
name: mingzi
pwd: abc
age: 39
the fourth step
test