一、正文
1、创建Spring Boot Web项目
2、添加依赖
3、添加项目名称和保存位置
4、创建自定义配置文件
5、创建自定义配置类
package net.zy.lesson04;
//学生配置类 2021.5.7
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
@Component //让Spring容器来管理Bean
@PropertySource("classpath:myconfig.properties") //加载自定义配置文件
@ConfigurationProperties(prefix = "student") // 此注解必须要Component注解
public class StudentConfig {
private String id;
private String name;
private int age;
public String getId() {
return id;
}
public void setId(String id