一、新建一个maven项目,引入springboot的自动配置jar包
<!-- 引入springboot的自动配置jar包-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>2.7.4</version>
</dependency>
二、创建一个student实体类,并自动读取properties中的配置
package com.aaa.entity;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties(prefix="student")
public class Student {
private int id;
private String name;
private String message;
public Student() {
}
public Student(int id, String name, String message) {
this.id = id;
this.name = name;
this.message = message;
}
public int get