保留src目录与pom.xml文件
![]()
![]()
![]()
//1.定义数据模型封装yaml文件中对应的数据 //2.定义为spring管控的bean @Component //3.指定加载的数据 @ConfigurationProperties(prefix = "datasource") public class MyDataSource { private String driver; private String url; private String username; private String password; @Override public String toString() { return "MyDataSource{" + "driver='" + driver + '\'' + ", url='" + url + '\'' + ", username='" + username + '\'' + ", password='" + password + '\'' + '}'; } //set,get方法省略
运行