一、populateBean
1.1 中文
填充对象属性
1.2 使用示例
populateMember()
填充组装Member信息
1.3 参考来源
1.3.1 Spring源码
Spring通过populateBean
方法给Bean实例填充属性。
![](https://img.haomeiwen.com/i9571610/4e3563789dc19ab3.png)
二、fillProperties
2.1 中文
填充属性
2.2 使用示例
fillMember()
填充组装Member信息
2.3 参考来源
2.3.1 Spring源码
Spring读取配置文件
![](https://img.haomeiwen.com/i9571610/d343109a0d6b49ff.png)
三、deduce
3.1 中文
推断
3.2 使用示例
deduceMainApplicationClass
,SpringBoot推断出主方法所在的类
3.3 参考来源
3.3.1 Spring源码
org.springframework.boot.SpringApplication
类
private Class<?> mainApplicationClass;
public SpringApplication(ResourceLoader resourceLoader, Class<?>... primarySources) {
this.resourceLoader = resourceLoader;
Assert.notNull(primarySources, "PrimarySources must not be null");
this.primarySources = new LinkedHashSet<>(Arrays.asList(primarySources));
this.webApplicationType = WebApplicationType.deduceFromClasspath();
this.bootstrapRegistryInitializers = new ArrayList<>(
getSpringFactoriesInstances(BootstrapRegistryInitializer.class));
setInitializers((Collection) getSpringFactoriesInstances(ApplicationContextInitializer.class));
setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class));
this.mainApplicationClass = deduceMainApplicationClass();
}
private Class<?> deduceMainApplicationClass() {
try {
StackTraceElement[] stackTrace = new RuntimeException().getStackTrace();
for (StackTraceElement stackTraceElement : stackTrace) {
if ("main".equals(stackTraceElement.getMethodName())) {
return Class.forName(stackTraceElement.getClassName());
}
}
}
catch (ClassNotFoundException ex) {
// Swallow and continue
}
return null;
}
四、Arguments / args
4.1 中文
参数
4.2 使用示例
public static void main(String[] args) {
SpringApplication.run(SpringbootTestApplication.class, args);
}
-
org.springframework.boot.ApplicationArguments
-
org.springframework.boot.DefaultApplicationArguments
4.3 参考来源
4.3.1 Spring源码
![](https://img.haomeiwen.com/i9571610/7efac9bedc68c2dd.png)
五、prepare
5.1 中文
准备
5.2 使用示例
org.springframework.boot.SpringApplication.prepareEnvironment()
java.sql.PreparedStatement
5.3 参考来源
5.3.1 Spring源码
![](https://img.haomeiwen.com/i9571610/c3efa144aaf9d0c5.png)
![](https://img.haomeiwen.com/i9571610/a413b2bc84db182d.png)
5.3.2 java.sql.PreparedStatement源码
![](https://img.haomeiwen.com/i9571610/dac03159405af596.png)
六、doXXX()
6.1 中文
做XXX
6.2 使用示例
doGetBean()
获取Bean
6.3 参考来源
6.3.1 Spring源码
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean()
![](https://img.haomeiwen.com/i9571610/aa66687705be9c29.png)
七、util
7.1 中文
工具
7.2 用法
1、用做包名,存放项目中的各种工具包。
2、建议:参考JDK源码,不要在后面加s,写成utils。
3、JDK中,java.util
包下的工具类类名,一般是在类名后面加s,而不是写成XxxxxUtil.java
7.3 参考来源
7.3.1 JDK源码
java.util
包下的工具类:Collections、Comparators、
网友评论