一、使用@PropertySource加载自定义配置文件
1、创建Spring Boot Web项目ConfigDemo01
2、创建自定义配置文件
3、创建自定义配置类
package configdemo01.config;
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")