style: update workflows and github actions

This commit is contained in:
yanglbme 2021-02-26 19:16:07 +08:00
parent a9eb7171bb
commit 9a554e968f
27 changed files with 116 additions and 116 deletions

View File

@ -13,5 +13,5 @@ jobs:
with: with:
github_token: ${{ github.token }} github_token: ${{ github.token }}
source_ref: ${{ github.ref }} source_ref: ${{ github.ref }}
target_branch: "main" target_branch: main
commit_message_template: "[Automated] Merged {source_ref} into {target_branch}" commit_message_template: "[Automated] Merged {source_ref} into {target_branch}"

View File

@ -20,6 +20,6 @@ jobs:
uses: creyD/prettier_action@v3.3 uses: creyD/prettier_action@v3.3
with: with:
prettier_options: --write **/*.{md} prettier_options: --write **/*.{md}
commit_message: "style: prettify code" commit_message: "style: prettify code or document"
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -77,7 +77,7 @@ public class StaticTextSqlNode implements SqlNode {
- `org.apache.ibatis.scripting.xmltags.DynamicContext#appendSql` - `org.apache.ibatis.scripting.xmltags.DynamicContext#appendSql`
```JAVA ```java
public void appendSql(String sql) { public void appendSql(String sql) {
sqlBuilder.add(sql); sqlBuilder.add(sql);
} }
@ -102,7 +102,7 @@ public class StaticTextSqlNode implements SqlNode {
![image-20191219152655746](../../../images/mybatis/image-20191219152655746.png) ![image-20191219152655746](../../../images/mybatis/image-20191219152655746.png)
```JAVA ```java
@Override @Override
public boolean apply(DynamicContext context) { public boolean apply(DynamicContext context) {
if (evaluator.evaluateBoolean(test, context.getBindings())) { if (evaluator.evaluateBoolean(test, context.getBindings())) {
@ -116,7 +116,7 @@ public class StaticTextSqlNode implements SqlNode {
- `evaluator.evaluateBoolean(test, context.getBindings())`方法 - `evaluator.evaluateBoolean(test, context.getBindings())`方法
```JAVA ```java
/** /**
* @param expression 判断语句,ID != null * @param expression 判断语句,ID != null
* @param parameterObject 参数列表 * @param parameterObject 参数列表
@ -135,7 +135,7 @@ public class StaticTextSqlNode implements SqlNode {
``` ```
```JAVA ```java
/** /**
* 取值 * 取值
* @param expression 判断语句,ID=NULL * @param expression 判断语句,ID=NULL

View File

@ -24,7 +24,7 @@
- 实体对象 - 实体对象
```JAVA ```java
public class HsLog { public class HsLog {
private Integer id; private Integer id;
@ -50,7 +50,7 @@
- DAO - DAO
```JAVA ```java
public interface HsLogDao { public interface HsLogDao {
List<HsLog> findAll(); List<HsLog> findAll();
@ -61,7 +61,7 @@
- 实现类 - 实现类
```JAVA ```java
public class HsLogDaoImpl extends JdbcDaoSupport implements HsLogDao { public class HsLogDaoImpl extends JdbcDaoSupport implements HsLogDao {
@ -154,7 +154,7 @@
- 运行方法 - 运行方法
```JAVA ```java
public class SpringJDBCSourceCode { public class SpringJDBCSourceCode {
public static void main(String[] args) { public static void main(String[] args) {
@ -251,7 +251,7 @@
- `org.springframework.jdbc.datasource.DataSourceUtils#releaseConnection` - `org.springframework.jdbc.datasource.DataSourceUtils#releaseConnection`
```JAVA ```java
public static void releaseConnection(@Nullable Connection con, @Nullable DataSource dataSource) { public static void releaseConnection(@Nullable Connection con, @Nullable DataSource dataSource) {
try { try {
doReleaseConnection(con, dataSource); doReleaseConnection(con, dataSource);
@ -289,7 +289,7 @@ public static void doReleaseConnection(@Nullable Connection con, @Nullable DataS
链接数 链接数
```JAVA ```java
/** /**
* Increase the reference count by one because the holder has been requested * Increase the reference count by one because the holder has been requested
* (i.e. someone requested the resource held by it). * (i.e. someone requested the resource held by it).
@ -412,7 +412,7 @@ public void setDataSource(@Nullable DataSource dataSource) {
} }
``` ```
```JAVA ```java
@Override @Override
public List<T> extractData(ResultSet rs) throws SQLException { public List<T> extractData(ResultSet rs) throws SQLException {
List<T> results = (this.rowsExpected > 0 ? new ArrayList<>(this.rowsExpected) : new ArrayList<>()); List<T> results = (this.rowsExpected > 0 ? new ArrayList<>(this.rowsExpected) : new ArrayList<>());

View File

@ -525,7 +525,7 @@ public class RMIClientSourceCode {
1. 调用父类的`afterPropertiesSet`方法判断`serviceUrl`是否为空 1. 调用父类的`afterPropertiesSet`方法判断`serviceUrl`是否为空
2. 执行`prepare()`方法 2. 执行`prepare()`方法
```JAVA ```java
public void prepare() throws RemoteLookupFailureException { public void prepare() throws RemoteLookupFailureException {
// Cache RMI stub on initialization? // Cache RMI stub on initialization?
if (this.lookupStubOnStartup) { if (this.lookupStubOnStartup) {
@ -553,7 +553,7 @@ public class RMIClientSourceCode {
#### org.springframework.remoting.rmi.RmiClientInterceptor#lookupStub #### org.springframework.remoting.rmi.RmiClientInterceptor#lookupStub
```JAVA ```java
protected Remote lookupStub() throws RemoteLookupFailureException { protected Remote lookupStub() throws RemoteLookupFailureException {
try { try {
Remote stub = null; Remote stub = null;
@ -625,7 +625,7 @@ protected Remote lookupStub() throws RemoteLookupFailureException {
- 通过类图我们可以知道`RmiProxyFactoryBean`实现了`MethodInterceptor`,具体实现方法在`org.springframework.remoting.rmi.RmiClientInterceptor#invoke` - 通过类图我们可以知道`RmiProxyFactoryBean`实现了`MethodInterceptor`,具体实现方法在`org.springframework.remoting.rmi.RmiClientInterceptor#invoke`
```JAVA ```java
@Override @Override
public Object invoke(MethodInvocation invocation) throws Throwable { public Object invoke(MethodInvocation invocation) throws Throwable {
// 获取remote // 获取remote
@ -649,7 +649,7 @@ protected Remote lookupStub() throws RemoteLookupFailureException {
``` ```
```JAVA ```java
protected Remote getStub() throws RemoteLookupFailureException { protected Remote getStub() throws RemoteLookupFailureException {
if (!this.cacheStub || (this.lookupStubOnStartup && !this.refreshStubOnConnectFailure)) { if (!this.cacheStub || (this.lookupStubOnStartup && !this.refreshStubOnConnectFailure)) {
// 如果缓存stub存在直接获取,否则创建 // 如果缓存stub存在直接获取,否则创建
@ -668,7 +668,7 @@ protected Remote lookupStub() throws RemoteLookupFailureException {
- `org.springframework.remoting.rmi.RmiClientInterceptor#doInvoke(org.aopalliance.intercept.MethodInvocation, org.springframework.remoting.rmi.RmiInvocationHandler)` - `org.springframework.remoting.rmi.RmiClientInterceptor#doInvoke(org.aopalliance.intercept.MethodInvocation, org.springframework.remoting.rmi.RmiInvocationHandler)`
```JAVA ```java
@Nullable @Nullable
protected Object doInvoke(MethodInvocation methodInvocation, RmiInvocationHandler invocationHandler) protected Object doInvoke(MethodInvocation methodInvocation, RmiInvocationHandler invocationHandler)
throws RemoteException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { throws RemoteException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
@ -693,7 +693,7 @@ protected Remote lookupStub() throws RemoteLookupFailureException {
- `org.springframework.remoting.rmi.RmiInvocationWrapper#invoke` - `org.springframework.remoting.rmi.RmiInvocationWrapper#invoke`
```JAVA ```java
/** /**
* Delegates the actual invocation handling to the RMI exporter. * Delegates the actual invocation handling to the RMI exporter.
* *
@ -712,7 +712,7 @@ protected Remote lookupStub() throws RemoteLookupFailureException {
- 继续跟踪`org.springframework.remoting.rmi.RmiBasedExporter#invoke` - 继续跟踪`org.springframework.remoting.rmi.RmiBasedExporter#invoke`
```JAVA ```java
@Override @Override
protected Object invoke(RemoteInvocation invocation, Object targetObject) protected Object invoke(RemoteInvocation invocation, Object targetObject)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
@ -723,7 +723,7 @@ protected Remote lookupStub() throws RemoteLookupFailureException {
- 继续跟踪`org.springframework.remoting.support.RemoteInvocationBasedExporter#invoke` - 继续跟踪`org.springframework.remoting.support.RemoteInvocationBasedExporter#invoke`
```JAVA ```java
protected Object invoke(RemoteInvocation invocation, Object targetObject) protected Object invoke(RemoteInvocation invocation, Object targetObject)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
@ -761,7 +761,7 @@ protected Remote lookupStub() throws RemoteLookupFailureException {
![image-20200226083247784](../../../images/spring/image-20200226083247784.png) ![image-20200226083247784](../../../images/spring/image-20200226083247784.png)
```JAVA ```java
public class DefaultRemoteInvocationExecutor implements RemoteInvocationExecutor { public class DefaultRemoteInvocationExecutor implements RemoteInvocationExecutor {
@Override @Override
@ -776,7 +776,7 @@ public class DefaultRemoteInvocationExecutor implements RemoteInvocationExecutor
} }
``` ```
```JAVA ```java
public Object invoke(Object targetObject) public Object invoke(Object targetObject)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {

View File

@ -86,7 +86,7 @@ public class JSONController {
- `org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#initCorsConfiguration` - `org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#initCorsConfiguration`
```JAVA ```java
@Override @Override
protected CorsConfiguration initCorsConfiguration(Object handler, Method method, RequestMappingInfo mappingInfo) { protected CorsConfiguration initCorsConfiguration(Object handler, Method method, RequestMappingInfo mappingInfo) {
// 重新创建,为什么不作为参数传递: 还有别的实现方法 // 重新创建,为什么不作为参数传递: 还有别的实现方法
@ -244,7 +244,7 @@ public class JSONController {
- 实现**BeanDefinitionParser** 接口的都有一个**parse**方法直接看方法. - 实现**BeanDefinitionParser** 接口的都有一个**parse**方法直接看方法.
- 通过查看我们可以知道最终目的获取 xml 标签中的属性,对 **CorsConfiguration**进行初始化,最后 Spring 中注册 - 通过查看我们可以知道最终目的获取 xml 标签中的属性,对 **CorsConfiguration**进行初始化,最后 Spring 中注册
```JAVA ```java
public class CorsBeanDefinitionParser implements BeanDefinitionParser { public class CorsBeanDefinitionParser implements BeanDefinitionParser {
@Override @Override
@ -341,7 +341,7 @@ public class CorsBeanDefinitionParser implements BeanDefinitionParser {
- 跨域信息 - 跨域信息
```JAVA ```java
/** /**
* 允许请求源 * 允许请求源
*/ */
@ -511,7 +511,7 @@ public class CorsBeanDefinitionParser implements BeanDefinitionParser {
![image-20200123093733129](../../../images/springMVC/clazz/image-20200123093733129.png) ![image-20200123093733129](../../../images/springMVC/clazz/image-20200123093733129.png)
```JAVA ```java
@Override @Override
@SuppressWarnings("resource") @SuppressWarnings("resource")
public boolean processRequest(@Nullable CorsConfiguration config, HttpServletRequest request, public boolean processRequest(@Nullable CorsConfiguration config, HttpServletRequest request,

View File

@ -505,7 +505,7 @@ public class DeclarativeTransactionTest {
- `tm.getTransaction` - `tm.getTransaction`
```JAVA ```java
@Override @Override
public final TransactionStatus getTransaction(@Nullable TransactionDefinition definition) public final TransactionStatus getTransaction(@Nullable TransactionDefinition definition)
throws TransactionException { throws TransactionException {
@ -577,7 +577,7 @@ public class DeclarativeTransactionTest {
- `org.springframework.jdbc.datasource.DataSourceTransactionManager#doGetTransaction` - `org.springframework.jdbc.datasource.DataSourceTransactionManager#doGetTransaction`
```JAVA ```java
@Override @Override
protected Object doGetTransaction() { protected Object doGetTransaction() {
DataSourceTransactionObject txObject = new DataSourceTransactionObject(); DataSourceTransactionObject txObject = new DataSourceTransactionObject();
@ -594,7 +594,7 @@ public class DeclarativeTransactionTest {
- `org.springframework.transaction.support.AbstractPlatformTransactionManager#suspend` - `org.springframework.transaction.support.AbstractPlatformTransactionManager#suspend`
```JAVA ```java
@Nullable @Nullable
protected final SuspendedResourcesHolder suspend(@Nullable Object transaction) protected final SuspendedResourcesHolder suspend(@Nullable Object transaction)
throws TransactionException { throws TransactionException {
@ -642,7 +642,7 @@ public class DeclarativeTransactionTest {
- `prepareTransactionInfo`简单的`new`对象并且绑定线程 - `prepareTransactionInfo`简单的`new`对象并且绑定线程
```JAVA ```java
protected TransactionInfo prepareTransactionInfo(@Nullable PlatformTransactionManager tm, protected TransactionInfo prepareTransactionInfo(@Nullable PlatformTransactionManager tm,
@Nullable TransactionAttribute txAttr, String joinpointIdentification, @Nullable TransactionAttribute txAttr, String joinpointIdentification,
@Nullable TransactionStatus status) { @Nullable TransactionStatus status) {
@ -1654,7 +1654,7 @@ static Object unwrapResourceIfNecessary(Object resource) {
- `ScopedProxyUnwrapper.unwrapIfNecessary` - `ScopedProxyUnwrapper.unwrapIfNecessary`
```JAVA ```java
private static class ScopedProxyUnwrapper { private static class ScopedProxyUnwrapper {
public static Object unwrapIfNecessary(Object resource) { public static Object unwrapIfNecessary(Object resource) {

View File

@ -30,7 +30,7 @@ public class DemoApplicationListener implements ApplicationListener {
</beans> </beans>
``` ```
```JAVA ```java
public class ListenerSourceCode { public class ListenerSourceCode {
public static void main(String[] args) { public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("Listener-demo.xml"); ApplicationContext context = new ClassPathXmlApplicationContext("Listener-demo.xml");
@ -68,7 +68,7 @@ public class ListenerSourceCode {
## 注册 ## 注册
```JAVA ```java
protected void registerListeners() { protected void registerListeners() {
// Register statically specified listeners first. // Register statically specified listeners first.
// 读取 ApplicationListener // 读取 ApplicationListener

View File

@ -399,7 +399,7 @@ public AbstractBeanDefinition parseBeanDefinitionElement(
- 将 xml 标签的数据读取到内存中设置给`AbstractBeanDefinition` - 将 xml 标签的数据读取到内存中设置给`AbstractBeanDefinition`
```JAVA ```java
public AbstractBeanDefinition parseBeanDefinitionAttributes(Element ele, String beanName, public AbstractBeanDefinition parseBeanDefinitionAttributes(Element ele, String beanName,
@Nullable BeanDefinition containingBean, AbstractBeanDefinition bd) { @Nullable BeanDefinition containingBean, AbstractBeanDefinition bd) {
@ -971,7 +971,7 @@ public Object parseIdRefElement(Element ele) {
- `org.springframework.beans.factory.xml.BeanDefinitionParserDelegate#parseValueElement` - `org.springframework.beans.factory.xml.BeanDefinitionParserDelegate#parseValueElement`
```JAVA ```java
public Object parseValueElement(Element ele, @Nullable String defaultTypeName) { public Object parseValueElement(Element ele, @Nullable String defaultTypeName) {
// It's a literal value. // It's a literal value.
// 获取 xml 中的文本变量 // 获取 xml 中的文本变量

View File

@ -80,11 +80,11 @@ public class BeanFactoryPostProcessorSourceCode {
- `org.springframework.context.support.AbstractApplicationContext#refresh` - `org.springframework.context.support.AbstractApplicationContext#refresh`
```JAVA ```java
invokeBeanFactoryPostProcessors(beanFactory); invokeBeanFactoryPostProcessors(beanFactory);
``` ```
```JAVA ```java
protected void invokeBeanFactoryPostProcessors(ConfigurableListableBeanFactory beanFactory) { protected void invokeBeanFactoryPostProcessors(ConfigurableListableBeanFactory beanFactory) {
PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(beanFactory, getBeanFactoryPostProcessors()); PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(beanFactory, getBeanFactoryPostProcessors());
@ -100,7 +100,7 @@ public class BeanFactoryPostProcessorSourceCode {
- `org.springframework.context.support.PostProcessorRegistrationDelegate#invokeBeanFactoryPostProcessors(org.springframework.beans.factory.config.ConfigurableListableBeanFactory, java.util.List<org.springframework.beans.factory.config.BeanFactoryPostProcessor>)` - `org.springframework.context.support.PostProcessorRegistrationDelegate#invokeBeanFactoryPostProcessors(org.springframework.beans.factory.config.ConfigurableListableBeanFactory, java.util.List<org.springframework.beans.factory.config.BeanFactoryPostProcessor>)`
```JAVA ```java
public static void invokeBeanFactoryPostProcessors( public static void invokeBeanFactoryPostProcessors(
ConfigurableListableBeanFactory beanFactory, List<BeanFactoryPostProcessor> beanFactoryPostProcessors) { ConfigurableListableBeanFactory beanFactory, List<BeanFactoryPostProcessor> beanFactoryPostProcessors) {
@ -373,13 +373,13 @@ public class DemoInstantiationAwareBeanPostProcessor implements InstantiationAwa
`org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#createBean(java.lang.String, org.springframework.beans.factory.support.RootBeanDefinition, java.lang.Object[])`中有如下代码 `org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#createBean(java.lang.String, org.springframework.beans.factory.support.RootBeanDefinition, java.lang.Object[])`中有如下代码
```JAVA ```java
Object bean = resolveBeforeInstantiation(beanName, mbdToUse); Object bean = resolveBeforeInstantiation(beanName, mbdToUse);
``` ```
- `org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#resolveBeforeInstantiation` - `org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#resolveBeforeInstantiation`
```JAVA ```java
@Nullable @Nullable
protected Object resolveBeforeInstantiation(String beanName, RootBeanDefinition mbd) { protected Object resolveBeforeInstantiation(String beanName, RootBeanDefinition mbd) {
Object bean = null; Object bean = null;
@ -405,7 +405,7 @@ public class DemoInstantiationAwareBeanPostProcessor implements InstantiationAwa
- `org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#applyBeanPostProcessorsBeforeInstantiation` - `org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#applyBeanPostProcessorsBeforeInstantiation`
```JAVA ```java
@Nullable @Nullable
protected Object applyBeanPostProcessorsBeforeInstantiation(Class<?> beanClass, String beanName) { protected Object applyBeanPostProcessorsBeforeInstantiation(Class<?> beanClass, String beanName) {
for (BeanPostProcessor bp : getBeanPostProcessors()) { for (BeanPostProcessor bp : getBeanPostProcessors()) {

View File

@ -30,7 +30,7 @@ public interface BeanNameGenerator {
- 调用工具类方法进行生成 - 调用工具类方法进行生成
```JAVA ```java
@Override @Override
public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) { public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
return BeanDefinitionReaderUtils.generateBeanName(definition, registry); return BeanDefinitionReaderUtils.generateBeanName(definition, registry);

View File

@ -315,7 +315,7 @@ public class DatePropertyEditor extends PropertyEditorSupport {
![image-20200117142800671](../../../images/spring/image-20200117142800671.png) ![image-20200117142800671](../../../images/spring/image-20200117142800671.png)
```JAVA ```java
@Nullable @Nullable
private Object convertForProperty( private Object convertForProperty(
@Nullable Object value, String propertyName, BeanWrapper bw, TypeConverter converter) { @Nullable Object value, String propertyName, BeanWrapper bw, TypeConverter converter) {
@ -332,7 +332,7 @@ public class DatePropertyEditor extends PropertyEditorSupport {
``` ```
```JAVA ```java
private Object doConvertTextValue(@Nullable Object oldValue, String newTextValue, PropertyEditor editor) { private Object doConvertTextValue(@Nullable Object oldValue, String newTextValue, PropertyEditor editor) {
try { try {
editor.setValue(oldValue); editor.setValue(oldValue);
@ -352,7 +352,7 @@ public class DatePropertyEditor extends PropertyEditorSupport {
- 调用用例编写的方法 - 调用用例编写的方法
```JAVA ```java
@Override @Override
public void setAsText(String text) throws IllegalArgumentException { public void setAsText(String text) throws IllegalArgumentException {
System.out.println(text); System.out.println(text);

View File

@ -271,7 +271,7 @@ public class XSDDemo {
- `org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver#getHandlerMappings`跟踪这个方法 - `org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver#getHandlerMappings`跟踪这个方法
```JAVA ```java
/** /**
* Load the specified NamespaceHandler mappings lazily. * Load the specified NamespaceHandler mappings lazily.
* *
@ -358,7 +358,7 @@ public class XSDDemo {
![image-20200109090456547](../../../images/spring/image-20200109090456547.png) ![image-20200109090456547](../../../images/spring/image-20200109090456547.png)
```JAVA ```java
public DefaultNamespaceHandlerResolver(@Nullable ClassLoader classLoader) { public DefaultNamespaceHandlerResolver(@Nullable ClassLoader classLoader) {
this(classLoader, DEFAULT_HANDLER_MAPPINGS_LOCATION); this(classLoader, DEFAULT_HANDLER_MAPPINGS_LOCATION);
} }
@ -382,7 +382,7 @@ public class XSDDemo {
``` ```
```JAVA ```java
/** /**
* Load the specified NamespaceHandler mappings lazily. * Load the specified NamespaceHandler mappings lazily.
* *
@ -628,7 +628,7 @@ public class UserNamespaceHandler extends NamespaceHandlerSupport {
执行`com.huifer.source.spring.parser.UserBeanDefinitionParser#doParse` 执行`com.huifer.source.spring.parser.UserBeanDefinitionParser#doParse`
```JAVA ```java
@Override @Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
// 获取 userName 标签属性值 // 获取 userName 标签属性值

View File

@ -99,7 +99,7 @@
2. `org.springframework.context.support.AbstractMessageSource#getMessageInternal` 2. `org.springframework.context.support.AbstractMessageSource#getMessageInternal`
```JAVA ```java
@Nullable @Nullable
protected String getMessageInternal(@Nullable String code, @Nullable Object[] args, @Nullable Locale locale) { protected String getMessageInternal(@Nullable String code, @Nullable Object[] args, @Nullable Locale locale) {
if (code == null) { if (code == null) {

View File

@ -92,7 +92,7 @@ public MutablePropertyValues(@Nullable PropertyValues original) {
### PropertyValue 的构造方法 ### PropertyValue 的构造方法
```JAVA ```java
public PropertyValue(PropertyValue original) { public PropertyValue(PropertyValue original) {
Assert.notNull(original, "Original must not be null"); Assert.notNull(original, "Original must not be null");
this.name = original.getName(); this.name = original.getName();

View File

@ -529,7 +529,7 @@ protected void beforeSingletonCreation(String beanName) {
- `org.springframework.beans.factory.support.FactoryBeanRegistrySupport#postProcessObjectFromFactoryBean` - `org.springframework.beans.factory.support.FactoryBeanRegistrySupport#postProcessObjectFromFactoryBean`
```JAVA ```java
protected Object postProcessObjectFromFactoryBean(Object object, String beanName) throws BeansException { protected Object postProcessObjectFromFactoryBean(Object object, String beanName) throws BeansException {
return object; return object;
} }
@ -582,7 +582,7 @@ protected void afterSingletonCreation(String beanName) {
- 代码现在进入的很深了,回到 doGetBean - 代码现在进入的很深了,回到 doGetBean
- `org.springframework.beans.factory.support.AbstractBeanFactory#doGetBean` - `org.springframework.beans.factory.support.AbstractBeanFactory#doGetBean`
```JAVA ```java
protected <T> T doGetBean(final String name, @Nullable final Class<T> requiredType, protected <T> T doGetBean(final String name, @Nullable final Class<T> requiredType,
@Nullable final Object[] args, boolean typeCheckOnly) throws BeansException { @Nullable final Object[] args, boolean typeCheckOnly) throws BeansException {
// 转换beanName // 转换beanName
@ -1183,7 +1183,7 @@ public Object getSingleton(String beanName, ObjectFactory<?> singletonFactory) {
- 两个核心方法 - 两个核心方法
```JAVA ```java
// Give BeanPostProcessors a chance to return a proxy instead of the target bean instance. // Give BeanPostProcessors a chance to return a proxy instead of the target bean instance.
Object bean = resolveBeforeInstantiation(beanName, mbdToUse); Object bean = resolveBeforeInstantiation(beanName, mbdToUse);
Object beanInstance = doCreateBean(beanName, mbdToUse, args); Object beanInstance = doCreateBean(beanName, mbdToUse, args);
@ -1870,7 +1870,7 @@ public void overrideDefaultEditor(Class<?> requiredType, PropertyEditor property
- `registerCustomEditor` - `registerCustomEditor`
```JAVA ```java
@Override @Override
public void registerCustomEditor(@Nullable Class<?> requiredType, @Nullable String propertyPath, PropertyEditor propertyEditor) { public void registerCustomEditor(@Nullable Class<?> requiredType, @Nullable String propertyPath, PropertyEditor propertyEditor) {
if (requiredType == null && propertyPath == null) { if (requiredType == null && propertyPath == null) {

View File

@ -368,7 +368,7 @@ public class DemoService {
- `org.springframework.context.annotation.AnnotationBeanNameGenerator#buildDefaultBeanName(org.springframework.beans.factory.config.BeanDefinition, org.springframework.beans.factory.support.BeanDefinitionRegistry)` - `org.springframework.context.annotation.AnnotationBeanNameGenerator#buildDefaultBeanName(org.springframework.beans.factory.config.BeanDefinition, org.springframework.beans.factory.support.BeanDefinitionRegistry)`
- `org.springframework.context.annotation.AnnotationBeanNameGenerator#buildDefaultBeanName(org.springframework.beans.factory.config.BeanDefinition)` - `org.springframework.context.annotation.AnnotationBeanNameGenerator#buildDefaultBeanName(org.springframework.beans.factory.config.BeanDefinition)`
```JAVA ```java
protected String buildDefaultBeanName(BeanDefinition definition) { protected String buildDefaultBeanName(BeanDefinition definition) {
// 获取bean class name // 获取bean class name
String beanClassName = definition.getBeanClassName(); String beanClassName = definition.getBeanClassName();
@ -381,7 +381,7 @@ public class DemoService {
``` ```
```JAVA ```java
@Configuration @Configuration
public class BeanConfig { public class BeanConfig {
@Scope(value =ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value =ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@ -496,7 +496,7 @@ static void processCommonDefinitionAnnotations(AnnotatedBeanDefinition abd, Anno
#### org.springframework.context.annotation.AnnotationConfigUtils#applyScopedProxyMode #### org.springframework.context.annotation.AnnotationConfigUtils#applyScopedProxyMode
```JAVA ```java
static BeanDefinitionHolder applyScopedProxyMode( static BeanDefinitionHolder applyScopedProxyMode(
ScopeMetadata metadata, BeanDefinitionHolder definition, BeanDefinitionRegistry registry) { ScopeMetadata metadata, BeanDefinitionHolder definition, BeanDefinitionRegistry registry) {

View File

@ -59,7 +59,7 @@ public class JmsBootstrapConfiguration {
#### afterSingletonsInstantiated #### afterSingletonsInstantiated
```JAVA ```java
@Override @Override
public void afterSingletonsInstantiated() { public void afterSingletonsInstantiated() {
// Remove resolved singleton classes from cache // Remove resolved singleton classes from cache
@ -108,7 +108,7 @@ public class JmsBootstrapConfiguration {
- 关注最后一行`this.registrar.afterPropertiesSet()` - 关注最后一行`this.registrar.afterPropertiesSet()`
```JAVA ```java
@Override @Override
public void afterPropertiesSet() { public void afterPropertiesSet() {
registerAllEndpoints(); registerAllEndpoints();
@ -131,7 +131,7 @@ public class JmsBootstrapConfiguration {
#### postProcessAfterInitialization #### postProcessAfterInitialization
```JAVA ```java
@Override @Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof AopInfrastructureBean || bean instanceof JmsListenerContainerFactory || if (bean instanceof AopInfrastructureBean || bean instanceof JmsListenerContainerFactory ||
@ -169,7 +169,7 @@ public class JmsBootstrapConfiguration {
``` ```
```JAVA ```java
protected void processJmsListener(JmsListener jmsListener, Method mostSpecificMethod, Object bean) { protected void processJmsListener(JmsListener jmsListener, Method mostSpecificMethod, Object bean) {
Method invocableMethod = AopUtils.selectInvocableMethod(mostSpecificMethod, bean.getClass()); Method invocableMethod = AopUtils.selectInvocableMethod(mostSpecificMethod, bean.getClass());
@ -302,7 +302,7 @@ public class JmsBootstrapConfiguration {
- 关键接口`JmsListenerContainerFactory<C extends MessageListenerContainer>` - 关键接口`JmsListenerContainerFactory<C extends MessageListenerContainer>`
```JAVA ```java
public interface JmsListenerContainerFactory<C extends MessageListenerContainer> { public interface JmsListenerContainerFactory<C extends MessageListenerContainer> {
/** /**

View File

@ -67,7 +67,7 @@
- 真正的转换过程 - 真正的转换过程
```JAVA ```java
@Override @Override
protected Object convertFromInternal(Message<?> message, Class<?> targetClass, @Nullable Object conversionHint) { protected Object convertFromInternal(Message<?> message, Class<?> targetClass, @Nullable Object conversionHint) {
Charset charset = getContentTypeCharset(getMimeType(message.getHeaders())); Charset charset = getContentTypeCharset(getMimeType(message.getHeaders()));
@ -79,7 +79,7 @@
### toMessage ### toMessage
```JAVA ```java
@Override @Override
@Nullable @Nullable
public final Message<?> toMessage(Object payload, @Nullable MessageHeaders headers) { public final Message<?> toMessage(Object payload, @Nullable MessageHeaders headers) {
@ -88,7 +88,7 @@
``` ```
```JAVA ```java
@Override @Override
@Nullable @Nullable
public final Message<?> toMessage(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) { public final Message<?> toMessage(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) {
@ -128,7 +128,7 @@
- `org.springframework.messaging.converter.StringMessageConverter#convertToInternal` - `org.springframework.messaging.converter.StringMessageConverter#convertToInternal`
```JAVA ```java
@Override @Override
@Nullable @Nullable
protected Object convertToInternal( protected Object convertToInternal(
@ -147,7 +147,7 @@
- 创建**Message**对象 - 创建**Message**对象
```JAVA ```java
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <T> Message<T> createMessage(@Nullable T payload, MessageHeaders messageHeaders) { public static <T> Message<T> createMessage(@Nullable T payload, MessageHeaders messageHeaders) {
Assert.notNull(payload, "Payload must not be null"); Assert.notNull(payload, "Payload must not be null");
@ -162,7 +162,7 @@
``` ```
```JAVA ```java
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Message<T> build() { public Message<T> build() {
if (this.originalMessage != null && !this.headerAccessor.isModified()) { if (this.originalMessage != null && !this.headerAccessor.isModified()) {

View File

@ -58,7 +58,7 @@ public final HandlerExecutionChain getHandler(HttpServletRequest request) throws
- `getHandlerInternal`方法是一个抽象方法 - `getHandlerInternal`方法是一个抽象方法
```JAVA ```java
@Nullable @Nullable
protected abstract Object getHandlerInternal(HttpServletRequest request) throws Exception; protected abstract Object getHandlerInternal(HttpServletRequest request) throws Exception;
``` ```
@ -346,7 +346,7 @@ public Map<String, String> decodePathVariables(HttpServletRequest request, Map<S
- 回到`org.springframework.web.servlet.handler.AbstractHandlerMethodMapping#getHandlerInternal` - 回到`org.springframework.web.servlet.handler.AbstractHandlerMethodMapping#getHandlerInternal`
```JAVA ```java
String lookupPath = getUrlPathHelper().getLookupPathForRequest(request); String lookupPath = getUrlPathHelper().getLookupPathForRequest(request);
``` ```
@ -391,7 +391,7 @@ protected HandlerMethod lookupHandlerMethod(String lookupPath, HttpServletReques
List<T> directPathMatches = this.mappingRegistry.getMappingsByUrl(lookupPath); List<T> directPathMatches = this.mappingRegistry.getMappingsByUrl(lookupPath);
``` ```
```JAVA ```java
@Nullable @Nullable
public List<T> getMappingsByUrl(String urlPath) { public List<T> getMappingsByUrl(String urlPath) {
return this.urlLookup.get(urlPath); return this.urlLookup.get(urlPath);

View File

@ -74,7 +74,7 @@ public class DemoController {
- `org.springframework.web.servlet.handler.AbstractHandlerMethodMapping#registerHandlerMethod` - `org.springframework.web.servlet.handler.AbstractHandlerMethodMapping#registerHandlerMethod`
```JAVA ```java
protected void registerHandlerMethod(Object handler, Method method, T mapping) { protected void registerHandlerMethod(Object handler, Method method, T mapping) {
this.mappingRegistry.register(mapping, handler, method); this.mappingRegistry.register(mapping, handler, method);
} }

View File

@ -263,7 +263,7 @@ private <T> List<T> createSpringFactoriesInstances(Class<T> type, Class<?>[] par
- 最终输出内容类:`org.springframework.boot.SpringBootBanner` - 最终输出内容类:`org.springframework.boot.SpringBootBanner`
```JAVA ```java
class SpringBootBanner implements Banner { class SpringBootBanner implements Banner {
private static final String[] BANNER = { "", " . ____ _ __ _ _", private static final String[] BANNER = { "", " . ____ _ __ _ _",
@ -297,7 +297,7 @@ private <T> List<T> createSpringFactoriesInstances(Class<T> type, Class<?>[] par
### createApplicationContext ### createApplicationContext
```JAVA ```java
protected ConfigurableApplicationContext createApplicationContext() { protected ConfigurableApplicationContext createApplicationContext() {
// 获取上下文类 // 获取上下文类
Class<?> contextClass = this.applicationContextClass; Class<?> contextClass = this.applicationContextClass;
@ -327,7 +327,7 @@ private <T> List<T> createSpringFactoriesInstances(Class<T> type, Class<?>[] par
- `this.applicationContextClass` 初始化方法 - `this.applicationContextClass` 初始化方法
```JAVA ```java
public SpringApplication(ResourceLoader resourceLoader, Class<?>... primarySources) { public SpringApplication(ResourceLoader resourceLoader, Class<?>... primarySources) {
this.resourceLoader = resourceLoader; this.resourceLoader = resourceLoader;
Assert.notNull(primarySources, "PrimarySources must not be null"); Assert.notNull(primarySources, "PrimarySources must not be null");
@ -342,7 +342,7 @@ private <T> List<T> createSpringFactoriesInstances(Class<T> type, Class<?>[] par
- `org.springframework.boot.WebApplicationType#deduceFromClasspath` - `org.springframework.boot.WebApplicationType#deduceFromClasspath`
```JAVA ```java
static WebApplicationType deduceFromClasspath() { static WebApplicationType deduceFromClasspath() {
if (ClassUtils.isPresent(WEBFLUX_INDICATOR_CLASS, null) && !ClassUtils.isPresent(WEBMVC_INDICATOR_CLASS, null) if (ClassUtils.isPresent(WEBFLUX_INDICATOR_CLASS, null) && !ClassUtils.isPresent(WEBMVC_INDICATOR_CLASS, null)
&& !ClassUtils.isPresent(JERSEY_INDICATOR_CLASS, null)) { && !ClassUtils.isPresent(JERSEY_INDICATOR_CLASS, null)) {
@ -364,7 +364,7 @@ private <T> List<T> createSpringFactoriesInstances(Class<T> type, Class<?>[] par
### prepareContext ### prepareContext
```JAVA ```java
private void prepareContext(ConfigurableApplicationContext context, ConfigurableEnvironment environment, private void prepareContext(ConfigurableApplicationContext context, ConfigurableEnvironment environment,
SpringApplicationRunListeners listeners, ApplicationArguments applicationArguments, Banner printedBanner) { SpringApplicationRunListeners listeners, ApplicationArguments applicationArguments, Banner printedBanner) {
// 上下文中设置环境 // 上下文中设置环境
@ -631,7 +631,7 @@ private int load(Object source) {
- 两种 runner 启动`ApplicationRunner``CommandLineRunner` - 两种 runner 启动`ApplicationRunner``CommandLineRunner`
```JAVA ```java
private void callRunners(ApplicationContext context, ApplicationArguments args) { private void callRunners(ApplicationContext context, ApplicationArguments args) {
List<Object> runners = new ArrayList<>(); List<Object> runners = new ArrayList<>();
runners.addAll(context.getBeansOfType(ApplicationRunner.class).values()); runners.addAll(context.getBeansOfType(ApplicationRunner.class).values());
@ -649,7 +649,7 @@ private int load(Object source) {
``` ```
```JAVA ```java
private void callRunner(ApplicationRunner runner, ApplicationArguments args) { private void callRunner(ApplicationRunner runner, ApplicationArguments args) {
try { try {
(runner).run(args); (runner).run(args);

View File

@ -575,7 +575,7 @@ private List<String> filter(List<String> configurations, AutoConfigurationMetada
- 在这里有一个关注点 循环方法`getAutoConfigurationImportFilters()` - 在这里有一个关注点 循环方法`getAutoConfigurationImportFilters()`
```JAVA ```java
protected List<AutoConfigurationImportFilter> getAutoConfigurationImportFilters() { protected List<AutoConfigurationImportFilter> getAutoConfigurationImportFilters() {
return SpringFactoriesLoader.loadFactories(AutoConfigurationImportFilter.class, this.beanClassLoader); return SpringFactoriesLoader.loadFactories(AutoConfigurationImportFilter.class, this.beanClassLoader);
} }

View File

@ -20,7 +20,7 @@
## ConfigurationPropertiesScan ## ConfigurationPropertiesScan
```JAVA ```java
@Target(ElementType.TYPE) @Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@ -39,7 +39,7 @@ public @interface ConfigurationPropertiesScan {}
## EnableConfigurationProperties ## EnableConfigurationProperties
```JAVA ```java
@Target(ElementType.TYPE) @Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@ -88,7 +88,7 @@ public @interface EnableConfigurationProperties {
### registerInfrastructureBeans ### registerInfrastructureBeans
```JAVA ```java
static void registerInfrastructureBeans(BeanDefinitionRegistry registry) { static void registerInfrastructureBeans(BeanDefinitionRegistry registry) {
// 属性绑定后置处理器 // 属性绑定后置处理器
ConfigurationPropertiesBindingPostProcessor.register(registry); ConfigurationPropertiesBindingPostProcessor.register(registry);
@ -102,7 +102,7 @@ public @interface EnableConfigurationProperties {
#### ConfigurationPropertiesBindingPostProcessor.register(registry) #### ConfigurationPropertiesBindingPostProcessor.register(registry)
```JAVA ```java
public static void register(BeanDefinitionRegistry registry) { public static void register(BeanDefinitionRegistry registry) {
Assert.notNull(registry, "Registry must not be null"); Assert.notNull(registry, "Registry must not be null");
// 是否存在 // 是否存在
@ -119,7 +119,7 @@ public @interface EnableConfigurationProperties {
#### ConfigurationPropertiesBeanDefinitionValidator.register(registry) #### ConfigurationPropertiesBeanDefinitionValidator.register(registry)
```JAVA ```java
static void register(BeanDefinitionRegistry registry) { static void register(BeanDefinitionRegistry registry) {
Assert.notNull(registry, "Registry must not be null"); Assert.notNull(registry, "Registry must not be null");
if (!registry.containsBeanDefinition(BEAN_NAME)) { if (!registry.containsBeanDefinition(BEAN_NAME)) {
@ -145,7 +145,7 @@ public @interface EnableConfigurationProperties {
- 源码开始,先找出刚才的对象`org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration` - 源码开始,先找出刚才的对象`org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration`
```JAVA ```java
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
@ConditionalOnClass(ServletRequest.class) @ConditionalOnClass(ServletRequest.class)
@ -158,7 +158,7 @@ public @interface EnableConfigurationProperties {
public class ServletWebServerFactoryAutoConfiguration {} public class ServletWebServerFactoryAutoConfiguration {}
``` ```
```JAVA ```java
/** /**
* 找出 {@link EnableConfigurationProperties} 注解标记的中的属性值,并且返回值不是void * 找出 {@link EnableConfigurationProperties} 注解标记的中的属性值,并且返回值不是void
* @param metadata * @param metadata
@ -196,7 +196,7 @@ public @interface EnableConfigurationProperties {
### postProcessBeforeInitialization ### postProcessBeforeInitialization
```JAVA ```java
@Override @Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
// 绑定 // 绑定
@ -272,7 +272,7 @@ public @interface EnableConfigurationProperties {
- `org.springframework.boot.context.properties.ConfigurationPropertiesBean#create` - `org.springframework.boot.context.properties.ConfigurationPropertiesBean#create`
```JAVA ```java
private static ConfigurationPropertiesBean create(String name, Object instance, Class<?> type, Method factory) { private static ConfigurationPropertiesBean create(String name, Object instance, Class<?> type, Method factory) {
// 找注解 // 找注解
ConfigurationProperties annotation = findAnnotation(instance, type, factory, ConfigurationProperties.class); ConfigurationProperties annotation = findAnnotation(instance, type, factory, ConfigurationProperties.class);
@ -365,7 +365,7 @@ BindResult<?> bind(ConfigurationPropertiesBean propertiesBean) {
##### findProperty ##### findProperty
```JAVA ```java
private ConfigurationProperty findProperty(ConfigurationPropertyName name, Context context) { private ConfigurationProperty findProperty(ConfigurationPropertyName name, Context context) {
if (name.isEmpty()) { if (name.isEmpty()) {
return null; return null;
@ -384,7 +384,7 @@ BindResult<?> bind(ConfigurationPropertiesBean propertiesBean) {
- `org.springframework.boot.context.properties.source.SpringConfigurationPropertySource#getConfigurationProperty` - `org.springframework.boot.context.properties.source.SpringConfigurationPropertySource#getConfigurationProperty`
```JAVA ```java
@Override @Override
public ConfigurationProperty getConfigurationProperty(ConfigurationPropertyName name) { public ConfigurationProperty getConfigurationProperty(ConfigurationPropertyName name) {
PropertyMapping[] mappings = getMapper().map(name); PropertyMapping[] mappings = getMapper().map(name);
@ -393,7 +393,7 @@ BindResult<?> bind(ConfigurationPropertiesBean propertiesBean) {
``` ```
```JAVA ```java
protected final ConfigurationProperty find(PropertyMapping[] mappings, ConfigurationPropertyName name) { protected final ConfigurationProperty find(PropertyMapping[] mappings, ConfigurationPropertyName name) {
for (PropertyMapping candidate : mappings) { for (PropertyMapping candidate : mappings) {
@ -409,7 +409,7 @@ BindResult<?> bind(ConfigurationPropertiesBean propertiesBean) {
``` ```
```JAVA ```java
private ConfigurationProperty find(PropertyMapping mapping) { private ConfigurationProperty find(PropertyMapping mapping) {
// 需要读取的配置信息的key // 需要读取的配置信息的key
String propertySourceName = mapping.getPropertySourceName(); String propertySourceName = mapping.getPropertySourceName();

View File

@ -116,7 +116,7 @@ protected void addPropertySources(ConfigurableEnvironment environment, ResourceL
- `org.springframework.boot.context.config.ConfigFileApplicationListener.Loader#load(org.springframework.boot.context.config.ConfigFileApplicationListener.Profile, org.springframework.boot.context.config.ConfigFileApplicationListener.DocumentFilterFactory, org.springframework.boot.context.config.ConfigFileApplicationListener.DocumentConsumer)` - `org.springframework.boot.context.config.ConfigFileApplicationListener.Loader#load(org.springframework.boot.context.config.ConfigFileApplicationListener.Profile, org.springframework.boot.context.config.ConfigFileApplicationListener.DocumentFilterFactory, org.springframework.boot.context.config.ConfigFileApplicationListener.DocumentConsumer)`
```JAVA ```java
private void load(Profile profile, DocumentFilterFactory filterFactory, DocumentConsumer consumer) { private void load(Profile profile, DocumentFilterFactory filterFactory, DocumentConsumer consumer) {
getSearchLocations().forEach( getSearchLocations().forEach(
// 本地路径 // 本地路径
@ -196,7 +196,7 @@ private void load(Profile profile, DocumentFilterFactory filterFactory, Document
### asDocuments ### asDocuments
```JAVA ```java
/** /**
* 将 {@link PropertySource} 转换成 {@link Document} * 将 {@link PropertySource} 转换成 {@link Document}
* @param loaded * @param loaded

View File

@ -57,7 +57,7 @@ public @interface EnableAutoConfiguration {
## getAutoConfigurationMetadata() ## getAutoConfigurationMetadata()
```JAVA ```java
@Override @Override
public void process(AnnotationMetadata annotationMetadata, DeferredImportSelector deferredImportSelector) { public void process(AnnotationMetadata annotationMetadata, DeferredImportSelector deferredImportSelector) {
Assert.state(deferredImportSelector instanceof AutoConfigurationImportSelector, Assert.state(deferredImportSelector instanceof AutoConfigurationImportSelector,
@ -87,7 +87,7 @@ public @interface EnableAutoConfiguration {
- `org.springframework.boot.autoconfigure.AutoConfigurationMetadataLoader#loadMetadata(java.lang.ClassLoader)` - `org.springframework.boot.autoconfigure.AutoConfigurationMetadataLoader#loadMetadata(java.lang.ClassLoader)`
```JAVA ```java
static AutoConfigurationMetadata loadMetadata(ClassLoader classLoader, String path) { static AutoConfigurationMetadata loadMetadata(ClassLoader classLoader, String path) {
try { try {
@ -141,7 +141,7 @@ public @interface EnableAutoConfiguration {
先说注解 先说注解
```JAVA ```java
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnClass(RedisOperations.class) @ConditionalOnClass(RedisOperations.class)
@EnableConfigurationProperties(RedisProperties.class) @EnableConfigurationProperties(RedisProperties.class)
@ -155,7 +155,7 @@ public @interface EnableAutoConfiguration {
- `org.springframework.boot.autoconfigure.data.redis.RedisProperties` - `org.springframework.boot.autoconfigure.data.redis.RedisProperties`
- 部分 redis 配置属性 - 部分 redis 配置属性
```JAVA ```java
@ConfigurationProperties(prefix = "spring.redis") @ConfigurationProperties(prefix = "spring.redis")
public class RedisProperties { public class RedisProperties {
@ -228,7 +228,7 @@ public class RedisProperties {
### getAutoConfigurationEntry ### getAutoConfigurationEntry
```JAVA ```java
protected AutoConfigurationEntry getAutoConfigurationEntry(AutoConfigurationMetadata autoConfigurationMetadata, protected AutoConfigurationEntry getAutoConfigurationEntry(AutoConfigurationMetadata autoConfigurationMetadata,
AnnotationMetadata annotationMetadata) { AnnotationMetadata annotationMetadata) {
if (!isEnabled(annotationMetadata)) { if (!isEnabled(annotationMetadata)) {
@ -302,7 +302,7 @@ public class RedisProperties {
- new 两个对象直接做数据转换,去重 - new 两个对象直接做数据转换,去重
```JAVA ```java
protected final <T> List<T> removeDuplicates(List<T> list) { protected final <T> List<T> removeDuplicates(List<T> list) {
return new ArrayList<>(new LinkedHashSet<>(list)); return new ArrayList<>(new LinkedHashSet<>(list));
} }
@ -311,7 +311,7 @@ public class RedisProperties {
### getExclusions ### getExclusions
```JAVA ```java
protected Set<String> getExclusions(AnnotationMetadata metadata, AnnotationAttributes attributes) { protected Set<String> getExclusions(AnnotationMetadata metadata, AnnotationAttributes attributes) {
Set<String> excluded = new LinkedHashSet<>(); Set<String> excluded = new LinkedHashSet<>();
// 获取属性 exclude 值转换成list // 获取属性 exclude 值转换成list
@ -327,7 +327,7 @@ public class RedisProperties {
### getExcludeAutoConfigurationsProperty ### getExcludeAutoConfigurationsProperty
```JAVA ```java
private List<String> getExcludeAutoConfigurationsProperty() { private List<String> getExcludeAutoConfigurationsProperty() {
if (getEnvironment() instanceof ConfigurableEnvironment) { if (getEnvironment() instanceof ConfigurableEnvironment) {
Binder binder = Binder.get(getEnvironment()); Binder binder = Binder.get(getEnvironment());
@ -345,7 +345,7 @@ public class RedisProperties {
- 修改启动类 - 修改启动类
```JAVA ```java
@SpringBootApplication(excludeName = { "org.sourcehot.service.HelloServiceAutoConfiguration" }) @SpringBootApplication(excludeName = { "org.sourcehot.service.HelloServiceAutoConfiguration" })
``` ```
@ -354,7 +354,7 @@ public class RedisProperties {
### checkExcludedClasses ### checkExcludedClasses
```JAVA ```java
private void checkExcludedClasses(List<String> configurations, Set<String> exclusions) { private void checkExcludedClasses(List<String> configurations, Set<String> exclusions) {
List<String> invalidExcludes = new ArrayList<>(exclusions.size()); List<String> invalidExcludes = new ArrayList<>(exclusions.size());
for (String exclusion : exclusions) { for (String exclusion : exclusions) {
@ -377,7 +377,7 @@ public class RedisProperties {
### filter ### filter
```JAVA ```java
private List<String> filter(List<String> configurations, AutoConfigurationMetadata autoConfigurationMetadata) { private List<String> filter(List<String> configurations, AutoConfigurationMetadata autoConfigurationMetadata) {
long startTime = System.nanoTime(); long startTime = System.nanoTime();
String[] candidates = StringUtils.toStringArray(configurations); String[] candidates = StringUtils.toStringArray(configurations);
@ -430,7 +430,7 @@ public class RedisProperties {
### fireAutoConfigurationImportEvents ### fireAutoConfigurationImportEvents
```JAVA ```java
private void fireAutoConfigurationImportEvents(List<String> configurations, Set<String> exclusions) { private void fireAutoConfigurationImportEvents(List<String> configurations, Set<String> exclusions) {
// 获取自动配置的监听器列表 // 获取自动配置的监听器列表
List<AutoConfigurationImportListener> listeners = getAutoConfigurationImportListeners(); List<AutoConfigurationImportListener> listeners = getAutoConfigurationImportListeners();
@ -456,7 +456,7 @@ public class RedisProperties {
- `org.springframework.boot.autoconfigure.AutoConfigurationImportListener#onAutoConfigurationImportEvent` 在执行自动配置时触发 , 实现类只有 **`ConditionEvaluationReportAutoConfigurationImportListener`** - `org.springframework.boot.autoconfigure.AutoConfigurationImportListener#onAutoConfigurationImportEvent` 在执行自动配置时触发 , 实现类只有 **`ConditionEvaluationReportAutoConfigurationImportListener`**
```JAVA ```java
@Override @Override
public void onAutoConfigurationImportEvent(AutoConfigurationImportEvent event) { public void onAutoConfigurationImportEvent(AutoConfigurationImportEvent event) {
if (this.beanFactory != null) { if (this.beanFactory != null) {
@ -482,7 +482,7 @@ public class RedisProperties {
- 后续的一些行为相对简单,直接放个源码了. - 后续的一些行为相对简单,直接放个源码了.
```JAVA ```java
@Override @Override
public void process(AnnotationMetadata annotationMetadata, DeferredImportSelector deferredImportSelector) { public void process(AnnotationMetadata annotationMetadata, DeferredImportSelector deferredImportSelector) {
Assert.state(deferredImportSelector instanceof AutoConfigurationImportSelector, Assert.state(deferredImportSelector instanceof AutoConfigurationImportSelector,

View File

@ -97,7 +97,7 @@ public static void registerGlobalNacosProperties(AnnotationAttributes attributes
- 贴出注解上的信息 - 贴出注解上的信息
```JAVA ```java
NacosProperties globalProperties() default @NacosProperties(username = USERNAME_PLACEHOLDER, password = PASSWORD_PLACEHOLDER, endpoint = ENDPOINT_PLACEHOLDER, namespace = NAMESPACE_PLACEHOLDER, accessKey = ACCESS_KEY_PLACEHOLDER, secretKey = SECRET_KEY_PLACEHOLDER, serverAddr = SERVER_ADDR_PLACEHOLDER, contextPath = CONTEXT_PATH_PLACEHOLDER, clusterName = CLUSTER_NAME_PLACEHOLDER, encode = ENCODE_PLACEHOLDER); NacosProperties globalProperties() default @NacosProperties(username = USERNAME_PLACEHOLDER, password = PASSWORD_PLACEHOLDER, endpoint = ENDPOINT_PLACEHOLDER, namespace = NAMESPACE_PLACEHOLDER, accessKey = ACCESS_KEY_PLACEHOLDER, secretKey = SECRET_KEY_PLACEHOLDER, serverAddr = SERVER_ADDR_PLACEHOLDER, contextPath = CONTEXT_PATH_PLACEHOLDER, clusterName = CLUSTER_NAME_PLACEHOLDER, encode = ENCODE_PLACEHOLDER);
``` ```
@ -527,7 +527,7 @@ public void createServiceIfAbsent(String namespaceId, String serviceName, boolea
- 在了解 map 结构后不难理解下面这个获取 Service 的方法了 - 在了解 map 结构后不难理解下面这个获取 Service 的方法了
```JAVA ```java
public Service getService(String namespaceId, String serviceName) { public Service getService(String namespaceId, String serviceName) {
if (serviceMap.get(namespaceId) == null) { if (serviceMap.get(namespaceId) == null) {
return null; return null;