聊聊SpringBoot中10个扩展点的定义以及执行时机

3,711 阅读20分钟

前言 :
Spring 的扩展点 是Spring易扩展的一个重要体现,熟悉这些扩展点的定义方式,以及其调用时机,可以在我们开发过程中游刃有余,进行各种骚操作。我个人觉得熟悉他们 并知道其原理,是非常有必要的,今天我们就一个个来看下。

本文总结出10个扩展点,如有遗漏,欢迎补充~

扩展点1

实现 ApplicationContextInitializer的initialize方法

  • 时机 : spring容器还没被刷新之前 准备阶段 this.prepareContext(context, environment, listeners, applicationArguments, printedBanner); 此时所有的配置文件都已经加载
/**
 * ApplicationContextInitializer扩展点演示 时机: spring容器还没被刷新之前
 *
 * <p>
 * 因为这时候spring容器还没被刷新,所以想要自己的扩展的生效,有以下三种方式:
 * <p>
 * 1.在启动类中用springApplication.addInitializers(new ApplicationContextInitializerPoint())语句加入
 * 2.配置文件配置context.initializer.classes=com.xzll.test.ApplicationContextInitializerPoint
 * 3.Spring SPI扩展,在spring.factories中加入org.springframework.context.ApplicationContextInitializer=com.xzll.test.ApplicationContextInitializerPoint
 * <p>
 * //TODO 目前我试了三种方式 只有第二种方式可以输出该类的打印语句 ,1和2都没有输出打印语句 目前不知原因为何。留作以后研究吧
 *
 * 这是整个spring容器在刷新之前初始化ConfigurableApplicationContext的回调接口,简单来说,就是在容器刷新之前调用此类的initialize方法。
 * 这个点允许被用户自己扩展。用户可以在整个spring容器还没被初始化之前做一些事情。
 * 可以想到的场景可能为,在最开始激活一些配置,或者利用这时候class还没被类加载器加载的时机,进行动态字节码注入等操作。
 */
public class ApplicationContextInitializerPoint implements ApplicationContextInitializer<ConfigurableApplicationContext> {

   @Override
   public void initialize(ConfigurableApplicationContext applicationContext) {

      // System.out.println("applicationContext: "+ JSON.toJSONString(applicationContext));
      // 注意这里引入不了FastJson 会报错 AnnotationConfigApplicationContext has not been refreshed yet  ; AnnotationConfigApplicationContext 尚未刷新
      // 详见: https://stackoverflow.com/questions/28404817/annotationconfigapplicationcontext-has-not-been-refreshed-yet-whats-wrong
      System.out.println("------------ApplicationContextInitializerPoint # initialize 开始-------------");
      System.out.println("[ApplicationContextInitializer扩展点演示] # initialize:  " + applicationContext.toString());
      System.out.println("BeanDefinitionCount count: " + applicationContext.getBeanDefinitionCount());
      ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
      Iterator<String> beanNamesIterator = beanFactory.getBeanNamesIterator();
      beanNamesIterator.forEachRemaining(System.out::println);
      System.out.println("时机: "+ "run 方法中的 this.prepareContext(); 的时候");
      System.out.println("-------------ApplicationContextInitializerPoint # initialize 结束------------");
      System.out.println();

   }

   /*

   private void prepareContext(ConfigurableApplicationContext context, ConfigurableEnvironment environment, SpringApplicationRunListeners listeners, ApplicationArguments applicationArguments, Banner printedBanner) {
        context.setEnvironment(environment);
        this.postProcessApplicationContext(context);
        this.applyInitializers(context);
        listeners.contextPrepared(context);
        if (this.logStartupInfo) {
            this.logStartupInfo(context.getParent() == null);
            this.logStartupProfileInfo(context);
        }

        ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
        beanFactory.registerSingleton("springApplicationArguments", applicationArguments);
        if (printedBanner != null) {
            beanFactory.registerSingleton("springBootBanner", printedBanner);
        }

        if (beanFactory instanceof DefaultListableBeanFactory) {
            ((DefaultListableBeanFactory)beanFactory).setAllowBeanDefinitionOverriding(this.allowBeanDefinitionOverriding);
        }

        Set<Object> sources = this.getAllSources();
        Assert.notEmpty(sources, "Sources must not be empty");
        this.load(context, sources.toArray(new Object[0]));
        listeners.contextLoaded(context);
    }


     protected void applyInitializers(ConfigurableApplicationContext context) {
        Iterator var2 = this.getInitializers().iterator();

        while(var2.hasNext()) {
            ApplicationContextInitializer initializer = (ApplicationContextInitializer)var2.next();
            Class<?> requiredType = GenericTypeResolver.resolveTypeArgument(initializer.getClass(), ApplicationContextInitializer.class);
            Assert.isInstanceOf(requiredType, context, "Unable to call initializer.");
            initializer.initialize(context);// todo 此处回调 initialize 方法
        }

    }

    */
}

扩展点2

实现 BeanDefinitionRegistryPostProcessor或BeanFactoryPostProcessor 的 postProcessBeanDefinitionRegistry 和 postProcessBeanFactory方法

  • 时机: refresh()的 this.invokeBeanFactoryPostProcessors(beanFactory);此时此bean的定义信息 都已经加载完毕 但是还没到实例化以及初始化阶段
@Component
public class BeanDefinitionRegistryPostProcessorPoint implements BeanDefinitionRegistryPostProcessor {

   @Override
   public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
      System.out.println("-----------------------[BeanDefinitionRegistryPostProcessor扩展点演示] # postProcessBeanDefinitionRegistry 开始--------------------------------------");
      System.out.println("[BeanDefinitionRegistryPostProcessor扩展点演示] # postProcessBeanDefinitionRegistry");
      System.out.println("时机: refresh()的 this.invokeBeanFactoryPostProcessors(beanFactory); 方法中执行; " +
            "此时 bean的定义信息 都已经加载完毕 但是还没到实例化以及初始化阶段");
      System.out.println("-----------------------[BeanDefinitionRegistryPostProcessor扩展点演示] # postProcessBeanDefinitionRegistry 结束--------------------------------------");
      System.out.println();
   }

   @Override
   public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
      System.out.println("-----------------------[BeanDefinitionRegistryPostProcessor扩展点演示] # postProcessBeanFactory 开始--------------------------------------");
      System.out.println("[BeanDefinitionRegistryPostProcessor扩展点演示] # postProcessBeanFactory");
      System.out.println("时机: refresh()的 this.invokeBeanFactoryPostProcessors(beanFactory); 方法中执行; " +
            "此时 bean的定义信息 都已经加载完毕 但是还没到实例化以及初始化阶段");
      System.out.println("-----------------------[BeanDefinitionRegistryPostProcessor扩展点演示] # postProcessBeanFactory 结束--------------------------------------");
      System.out.println();
   }
}
@Component
public class BeanFactoryPostProcessorPoint implements BeanFactoryPostProcessor {
   @Override
   public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
      System.out.println("-----------------------[BeanFactoryPostProcessor扩展点演示] # postProcessBeanFactory 开始--------------------------------------");
      System.out.println("[BeanFactoryPostProcessor扩展点演示] # postProcessBeanFactory");
      System.out.println("时机: refresh()的 this.invokeBeanFactoryPostProcessors(beanFactory); 方法中执行; " +
            "此时 bean的定义信息 都已经加载完毕 但是还没到实例化以及初始化阶段");
      System.out.println("-----------------------[BeanFactoryPostProcessor扩展点演示] # postProcessBeanFactory 结束--------------------------------------");
      System.out.println();
   }
}

扩展点3

实现 BeanPostProcessor 的 postProcessBeforeInitialization 或postProcessAfterInitialization方法

时机: bean在初始化之前(postProcessBeforeInitialization) 和初始化之后(postProcessAfterInitialization),注意 初始化前说明其肯定已经实例化了

@Configuration
public class BeanPostProcessPoint implements BeanPostProcessor {


   public BeanPostProcessPoint() {
      System.out.println();
      System.out.println("################## BeanPostProcessPoint 的构造方法 ##################");
      System.out.println();
   }

   /**
    * bean初始化之前
    *
    * @param bean
    * @param beanName
    * @return
    * @throws BeansException
    */
   @Override
   public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
      /**
       * 可以根据需要在这里进行某个bean的扩展
       */
      if (bean instanceof TestController) {
         System.out.println("-----------------------[BeanPostProcessPoint]  扩展点演示 # postProcessBeforeInitialization  开始--------------------------------------");
         System.out.println("[BeanPostProcessPoint]  扩展点演示 # postProcessBeforeInitialization , crurrentBeanName: " + beanName);
         System.out.println("这里只有当bean是TestController时候才打印 否则的话控制台要爆满了 根本看不清 ");
         System.out.println("时机 bean实例化后,初始化之前");
         System.out.println("-----------------------[BeanPostProcessPoint]  扩展点演示 # postProcessBeforeInitialization  结束--------------------------------------");
         System.out.println();
      }
      return bean;
   }

   /**
    * bean初始化之后
    *
    * @param bean
    * @param beanName
    * @return
    * @throws BeansException
    */
   @Override
   public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
      /**
       * 可以根据需要在这里进行某个bean的扩展
       */
      if (bean instanceof TestController) {
         System.out.println("-----------------------[BeanPostProcessPoint]  扩展点演示 # postProcessAfterInitialization  开始--------------------------------------");
         System.out.println("[BeanPostProcessPoint]  扩展点演示 # postProcessAfterInitialization , crurrentBeanName: " + beanName);
         System.out.println("这里只有当bean是TestController时候才打印 否则的话控制台要爆满了 根本看不清 ");
         System.out.println("时机 bean初始化后");
         System.out.println("-----------------------[BeanPostProcessPoint]  扩展点演示 # postProcessAfterInitialization  结束--------------------------------------");
         System.out.println();
      }
      return bean;
   }



   /*

   AbstractAutowireCapableBeanFactory的这个方法


   protected Object initializeBean(String beanName, Object bean, @Nullable RootBeanDefinition mbd) {
        if (System.getSecurityManager() != null) {
            AccessController.doPrivileged(() -> {
                this.invokeAwareMethods(beanName, bean);
                return null;
            }, this.getAccessControlContext());
        } else {
            this.invokeAwareMethods(beanName, bean);
        }

        Object wrappedBean = bean;
        if (mbd == null || !mbd.isSynthetic()) {
            wrappedBean = this.applyBeanPostProcessorsBeforeInitialization(bean, beanName);
        }

        try {
            this.invokeInitMethods(beanName, wrappedBean, mbd);
        } catch (Throwable var6) {
            throw new BeanCreationException(mbd != null ? mbd.getResourceDescription() : null, beanName, "Invocation of init method failed", var6);
        }

        if (mbd == null || !mbd.isSynthetic()) {
            wrappedBean = this.applyBeanPostProcessorsAfterInitialization(wrappedBean, beanName);
        }

        return wrappedBean;
    }


     public Object applyBeanPostProcessorsBeforeInitialization(Object existingBean, String beanName) throws BeansException {
        Object result = existingBean;

        Object current;
        for(Iterator var4 = this.getBeanPostProcessors().iterator(); var4.hasNext(); result = current) {
            BeanPostProcessor processor = (BeanPostProcessor)var4.next();
            current = processor.postProcessBeforeInitialization(result, beanName); //TODO 回调postProcessBeforeInitialization方法 在此处  postProcessAfterInitialization方法就不看了 一样的逻辑
            if (current == null) {
                return result;
            }
        }

        return result;
    }

    */
}

扩展点4

实现 InitializingBean的 afterPropertiesSet方法

时机: bean实例化并属性赋值之后他其实与上边扩展点3的关系 是 postProcessBeforeInitialization -> initializingBean -> postProcessAfterInitialization 理解扩展点3,你也就知道这个的时机了

注意:afterPropertiesSet发生作用的时机是当前类的实例化的时候,而BeanPostProcessor则是所有类,这也是为什么afterPropertiesSet的函数中没有参数

@Component
public class InitializingBeanPoint implements InitializingBean {
   public InitializingBeanPoint() {
      System.out.println();
      System.out.println("################## InitializingBeanPoint 的构造方法 ################## ");
      System.out.println();
   }

   @Override
   public void afterPropertiesSet() throws Exception {
      System.out.println("-----------------------[InitializingBeanPoint]  扩展点演示 # afterPropertiesSet  开始--------------------------------------");
      System.out.println("[InitializingBean] # afterPropertiesSet");
      System.out.println("时机: bean实例化后 AbstractAutowireCapableBeanFactory 类的 initializeBean方法 中的 invokeInitMethods(beanName, wrappedBean, mbd);");
      System.out.println("-----------------------[InitializingBeanPoint]  扩展点演示 # afterPropertiesSet  结束--------------------------------------");
      System.out.println();
   }

   /*
   AbstractAutowireCapableBeanFactory的这个方法
   protected Object initializeBean(String beanName, Object bean, @Nullable RootBeanDefinition mbd) {
        if (System.getSecurityManager() != null) {
            AccessController.doPrivileged(() -> {
                this.invokeAwareMethods(beanName, bean);
                return null;
            }, this.getAccessControlContext());
        } else {
            this.invokeAwareMethods(beanName, bean);
        }

        Object wrappedBean = bean;
        if (mbd == null || !mbd.isSynthetic()) {
            wrappedBean = this.applyBeanPostProcessorsBeforeInitialization(bean, beanName);
        }

        try {
            this.invokeInitMethods(beanName, wrappedBean, mbd);
        } catch (Throwable var6) {
            throw new BeanCreationException(mbd != null ? mbd.getResourceDescription() : null, beanName, "Invocation of init method failed", var6);
        }

        if (mbd == null || !mbd.isSynthetic()) {
            wrappedBean = this.applyBeanPostProcessorsAfterInitialization(wrappedBean, beanName);
        }

        return wrappedBean;
    }


    protected void invokeInitMethods(String beanName, Object bean, @Nullable RootBeanDefinition mbd) throws Throwable {
        boolean isInitializingBean = bean instanceof InitializingBean;
        if (isInitializingBean && (mbd == null || !mbd.isExternallyManagedInitMethod("afterPropertiesSet"))) {
            if (this.logger.isTraceEnabled()) {
                this.logger.trace("Invoking afterPropertiesSet() on bean with name '" + beanName + "'");
            }

            if (System.getSecurityManager() != null) {
                try {
                    AccessController.doPrivileged(() -> {
                        ((InitializingBean)bean).afterPropertiesSet();
                        return null;
                    }, this.getAccessControlContext());
                } catch (PrivilegedActionException var6) {
                    throw var6.getException();
                }
            } else {
                ((InitializingBean)bean).afterPropertiesSet();//TODO 回调在此处
            }
        }

        if (mbd != null && bean.getClass() != NullBean.class) {
            String initMethodName = mbd.getInitMethodName();
            if (StringUtils.hasLength(initMethodName) && (!isInitializingBean || !"afterPropertiesSet".equals(initMethodName)) && !mbd.isExternallyManagedInitMethod(initMethodName)) {
                this.invokeCustomInitMethod(beanName, bean, mbd);
            }
        }

    }
    */
}

扩展点5

初始化方法(方法名称你随意定就行)然后在方法上加 @PostConstruct注解即可,或者加上 @PreDestroy注解

时机: 初始化完成之后调用(@PostConstruct)所在的方法; 销毁之前调用(@PreDestroy)所在的方法

@Component
public class PostConstructPoint {

   public PostConstructPoint() {
      System.out.println();
      System.out.println("################## PostConstructPoint的构造方法 ################## ");
      System.out.println();
   }

   @PostConstruct
   public void init(){
      System.out.println();
      System.out.println("-----------------------[PostConstructPoint]  扩展点演示 @PostConstruct 开始--------------------------------------");
      System.out.println("[PostConstructPoint执行时机演示]");
      System.out.println("-----------------------[PostConstructPoint]  扩展点演示 @PostConstruct 结束--------------------------------------");
      System.out.println();
   }

   @PreDestroy
   public void destroy(){
      System.out.println();
      System.out.println("-----------------------[PostConstructPoint]  扩展点演示 @PreDestroy 开始--------------------------------------");
      System.out.println("[PostConstructPoint执行时机演示]");
      System.out.println("-----------------------[PostConstructPoint]  扩展点演示 @PreDestroy 结束--------------------------------------");
      System.out.println();
   }
}

扩展点6

实现 BeanNameAware 的 setBeanName方法

  • 注意 从源码可以看出 还可以实现 BeanClassLoaderAware 的 setBeanClassLoader方法,以及 BeanFactoryAware 的 setBeanFactory方法 时机: bean实例化之后 初始化之前 作用的话从方法名就知道这里不在赘述
@Component
public class BeanNameAwarePoint implements BeanNameAware {

   @Override
   public void setBeanName(String name) {
      System.out.println("------------BeanNameAwarePoint # setBeanName 开始-------------");
      System.out.println("[BeanNameAwarePoint]  扩展点演示 # setBeanName name: "+name);
      System.out.println("------------BeanNameAwarePoint # setBeanName 结束-------------");
      System.out.println();
   }

/*

AbstractAutowireCapableBeanFactory  类的


protected Object initializeBean(String beanName, Object bean, @Nullable RootBeanDefinition mbd) {
        if (System.getSecurityManager() != null) {
            AccessController.doPrivileged(() -> {
                this.invokeAwareMethods(beanName, bean);
                return null;
            }, this.getAccessControlContext());
        } else {
            this.invokeAwareMethods(beanName, bean);
        }

        Object wrappedBean = bean;
        if (mbd == null || !mbd.isSynthetic()) {
            wrappedBean = this.applyBeanPostProcessorsBeforeInitialization(bean, beanName);
        }

        try {
            this.invokeInitMethods(beanName, wrappedBean, mbd);
        } catch (Throwable var6) {
            throw new BeanCreationException(mbd != null ? mbd.getResourceDescription() : null, beanName, "Invocation of init method failed", var6);
        }

        if (mbd == null || !mbd.isSynthetic()) {
            wrappedBean = this.applyBeanPostProcessorsAfterInitialization(wrappedBean, beanName);
        }

        return wrappedBean;
    }


    private void invokeAwareMethods(String beanName, Object bean) {
        if (bean instanceof Aware) {
            if (bean instanceof BeanNameAware) {
                ((BeanNameAware)bean).setBeanName(beanName); //TODO 此处回调 BeanNameAware 的 setBeanName方法
            }

            if (bean instanceof BeanClassLoaderAware) {
                ClassLoader bcl = this.getBeanClassLoader();
                if (bcl != null) {
                    ((BeanClassLoaderAware)bean).setBeanClassLoader(bcl);//TODO 此处回调 BeanClassLoaderAware 的 setBeanClassLoader方法
                }
            }

            if (bean instanceof BeanFactoryAware) {
                ((BeanFactoryAware)bean).setBeanFactory(this);//TODO 此处回调 BeanFactoryAware 的 setBeanFactory方法
            }
        }

    }


 */

}

扩展点7

实现 CommandLineRunner 的run方法 或者 ApplicationRunner的run方法

从原代码中可以看出 这俩函数的调用顺序

时机: 容器刷新完成后

  • 实现 ApplicationRunner
@Component
public class ApplicationRunnerPoint implements ApplicationRunner {

   @Override
   public void run(ApplicationArguments args) throws Exception {
      System.out.println("-----------------------[ApplicationRunnerPoint]  扩展点演示 # run  开始--------------------------------------");
      System.out.println("[ApplicationRunnerPoint] # run ; "+"时机:此时已经刷新容器处于run方法的后半部分了 接下来run方法将发布running事件");
      System.out.println("-----------------------[ApplicationRunnerPoint]  扩展点演示 # run  结束--------------------------------------");
      System.out.println();
   }
   /*

   SpringApplication 类的 run方法中的 callRunners


   private void callRunners(ApplicationContext context, ApplicationArguments args) {
        List<Object> runners = new ArrayList();
        runners.addAll(context.getBeansOfType(ApplicationRunner.class).values());
        runners.addAll(context.getBeansOfType(CommandLineRunner.class).values());
        AnnotationAwareOrderComparator.sort(runners);
        Iterator var4 = (new LinkedHashSet(runners)).iterator();

        while(var4.hasNext()) {
            Object runner = var4.next();
            if (runner instanceof ApplicationRunner) {
                this.callRunner((ApplicationRunner)runner, args);
            }

            if (runner instanceof CommandLineRunner) {
                this.callRunner((CommandLineRunner)runner, args);
            }
        }

    }

    */
}
  • 实现 CommandLineRunner
@Component
public class CommandLineRunnerPoint implements CommandLineRunner {
   @Override
   public void run(String... args) throws Exception {
      System.out.println("-----------------------[CommandLineRunnerPoint]  扩展点演示 # run  开始--------------------------------------");
      System.out.println("[CommandLineRunnerPoint] # run ; "+"时机:此时已经刷新容器处于run方法的后半部分了 接下来run方法将发布running事件");
      System.out.println("-----------------------[CommandLineRunnerPoint]  扩展点演示 # run  结束--------------------------------------");
      System.out.println();
   }
   /*

   SpringApplication 类的 run方法中的 callRunners


   private void callRunners(ApplicationContext context, ApplicationArguments args) {
        List<Object> runners = new ArrayList();
        runners.addAll(context.getBeansOfType(ApplicationRunner.class).values());
        runners.addAll(context.getBeansOfType(CommandLineRunner.class).values());
        AnnotationAwareOrderComparator.sort(runners);
        Iterator var4 = (new LinkedHashSet(runners)).iterator();

        while(var4.hasNext()) {
            Object runner = var4.next();
            if (runner instanceof ApplicationRunner) {
                this.callRunner((ApplicationRunner)runner, args);
            }

            if (runner instanceof CommandLineRunner) {
                this.callRunner((CommandLineRunner)runner, args);
            }
        }

    }

    */
}

扩展点8

bean销毁时候(也算一个扩展点吧我个人觉得)

@Component
public class DisposableBeanPoint implements DisposableBean {
   @Override
   public void destroy() throws Exception {
      System.out.println("[DisposableBeanPoint] DisposableBeanPoint");
   }
}

扩展点9

实现 InstantiationAwareBeanPostProcessor的 这几个方法

  • postProcessBeforeInitialization
  • postProcessAfterInitialization
  • postProcessBeforeInstantiation
  • postProcessAfterInstantiation
  • postProcessPropertyValues(注意他已经标记为@Deprecated)我的springboot版本中他被 postProcessProperties替换了

发现没其实 InstantiationAwareBeanPostProcessor也是个 BeanPostProcessor

@Component
public class InstantiationAwareBeanPostProcessorPoint implements InstantiationAwareBeanPostProcessor {
   @Override
   public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
//    System.out.println("[InstantiationAwareBeanPostProcessorPoint] before initialization " + beanName);
      return bean;
   }

   @Override
   public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
//    System.out.println("[InstantiationAwareBeanPostProcessorPoint] after initialization " + beanName);
      return bean;
   }

   @Override
   public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
//    System.out.println("[InstantiationAwareBeanPostProcessorPoint] before instantiation " + beanName);
      return null;
   }

   @Override
   public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException {
//    System.out.println("[InstantiationAwareBeanPostProcessorPoint] after instantiation " + beanName);
      return true;
   }

   @Override
   public PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {
//    System.out.println("[InstantiationAwareBeanPostProcessorPoint] postProcessPropertyValues " + beanName);
      return pvs;
   }
   
}
  • 注意: 这个方法我们就不做打印了 因为打印的话 控制台刷的爆满这里解释下这几个方法的作用吧

InstantiationAwareBeanPostProcessor 小结

  1. InstantiationAwareBeanPostProcessor接口继承BeanPostProcessor接口,它内部提供了3个方法,再加上BeanPostProcessor接口内部的2个方法,所以实现这个接口需要实现5个方法。InstantiationAwareBeanPostProcessor接口的主要作用在于目标对象的实例化过程中需要处理的事情,包括实例化对象的前后过程以及实例的属性设置
  2. postProcessBeforeInstantiation (InstantiationAwareBeanPostProcessor自己的) 方法是最先执行的方法,它在目标对象实例化之前调用,该方法的返回值类型是Object,我们可以返回任何类型的值。由于这个时候目标对象还未实例化,所以这个返回值可以用来代替原本该生成的目标对象的实例(比如代理对象)。如果该方法的返回值代替原本该生成的目标对象,后续只有postProcessAfterInitialization方法会调用,其它方法不再调用;否则按照正常的流程走
  3. postProcessAfterInstantiation (InstantiationAwareBeanPostProcessor自己的) 方法在目标对象实例化之后调用,这个时候对象已经被实例化,但是该实例的属性还未被设置,都是null。如果该方法返回false,会忽略属性值的设置;如果返回true,会按照正常流程设置属性值
  4. postProcessPropertyValues(我这个springboot版本(2.1.x)已经被 postProcessProperties替换) (InstantiationAwareBeanPostProcessor自己的) 方法对属性值进行修改(这个时候属性值还未被设置,但是我们可以修改原本该设置进去的属性值)。如果postProcessProperties方法返回false,该方法不会被调用。可以在该方法内对属性值进行修改
  5. 父接口BeanPostProcessor的2个方法postProcessBeforeInitializationpostProcessAfterInitialization是在对象被实例化之后 (一个是在初始化之前,一个是在初始化之后调用)
  6. Instantiation表示实例化,Initialization表示初始化。实例化前的意思在对象还未生成,初始化前的意思在对象已经生成,但是属性还没有赋值阶段

扩展点10

  • 实现SmartInstantiationAwareBeanPostProcessor的这三个方法 (其实不止3个 一共有8个 ) 其实 SmartInstantiationAwareBeanPostProcessor(自有三个方法) 他也是继承了 InstantiationAwareBeanPostProcessor(即上边的扩展点9 他自有3个方法) 而 InstantiationAwareBeanPostProcessor继承了 BeanPostProcessor(自有2个方法)

所以我们说 SmartInstantiationAwareBeanPostProcessor 其实一共有8个方法可以实现 这里我们只看下 SmartInstantiationAwareBeanPostProcessor 自有的3个方法

  • predictBeanType
  • determineCandidateConstructors
  • getEarlyBeanReference
@Component
public class SmartInstantiationAwareBeanPostProcessorPoint implements SmartInstantiationAwareBeanPostProcessor {


   @Override
   public Class<?> predictBeanType(Class<?> beanClass, String beanName) throws BeansException {
//    System.out.println("[SmartInstantiationAwareBeanPostProcessorPoint] predictBeanType " + beanName);
      return beanClass;
   }

   @Override
   public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName) throws BeansException {
//    System.out.println("[SmartInstantiationAwareBeanPostProcessorPoint] determineCandidateConstructors " + beanName);
      return null;
   }

   @Override
   public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException {
//    System.out.println("[SmartInstantiationAwareBeanPostProcessorPoint] getEarlyBeanReference " + beanName);
      return bean;
   }

   /*

   AbstractAutowireCapableBeanFactory类的这个方法 predictBeanType

   protected Class<?> predictBeanType(String beanName, RootBeanDefinition mbd, Class<?>... typesToMatch) {
        Class<?> targetType = this.determineTargetType(beanName, mbd, typesToMatch);
        if (targetType != null && !mbd.isSynthetic() && this.hasInstantiationAwareBeanPostProcessors()) {
            Iterator var5 = this.getBeanPostProcessors().iterator();

            while(var5.hasNext()) {
                BeanPostProcessor bp = (BeanPostProcessor)var5.next();
                if (bp instanceof SmartInstantiationAwareBeanPostProcessor) {
                    SmartInstantiationAwareBeanPostProcessor ibp = (SmartInstantiationAwareBeanPostProcessor)bp;
                    Class<?> predicted = ibp.predictBeanType(targetType, beanName);
                    if (predicted != null && (typesToMatch.length != 1 || FactoryBean.class != typesToMatch[0] || FactoryBean.class.isAssignableFrom(predicted))) {
                        return predicted;
                    }
                }
            }
        }

        return targetType;
    }

    */

}
  • 注意这个和上边扩展点9一样 我们也不做打印了,这里总结下该扩展点几个方法的作用

SmartInstantiationAwareBeanPostProcessor 小结

  1. SmartInstantiationAwareBeanPostProcessor接口继承InstantiationAwareBeanPostProcessor接口,它内部提供了3个方法,再加上父接口的5个方法,所以实现这个接口需要实现8个方法。SmartInstantiationAwareBeanPostProcessor接口的主要作用也是在于目标对象的实例化过程中需要处理的事情。它是InstantiationAwareBeanPostProcessor接口的一个扩展。主要在Spring框架内部使用
  2. predictBeanType方法用于预测Bean的类型,返回第一个预测成功的Class类型,如果不能预测返回null。主要在于BeanDefinition无法确定Bean类型的时候调用该方法来确定类型
  3. determineCandidateConstructors方法用于选择合适的构造器,比如类有多个构造器,可以实现这个方法选择合适的构造器并用于实例化对象。该方法在postProcessBeforeInstantiation方法和postProcessAfterInstantiation方法之间调用,如果postProcessBeforeInstantiation方法返回了一个新的实例代替了原本该生成的实例,那么该方法会被忽略
  4. getEarlyBeanReference主要用于解决 循环依赖 问题。比如ReferenceA实例内部有ReferenceB的引用,ReferenceB实例内部有ReferenceA的引用。首先先实例化ReferenceA,实例化完成之后提前把这个bean暴露在ObjectFactory中,然后populate属性,这个时候发现需要ReferenceB。然后去实例化ReferenceB,在实例化ReferenceB的时候它需要ReferenceA的实例才能继续,这个时候就会去ObjectFactory中找出了ReferenceA实例,ReferenceB顺利实例化。ReferenceB实例化之后,ReferenceA的populate属性过程也成功完成,注入了ReferenceB实例。提前把这个bean暴露在ObjectFactory中,这个ObjectFactory获取的实例就是通过getEarlyBeanReference方法得到的
  • 另外关于循环依赖这里附上一张图片 (看这张图前,最好要知道spring中的一级缓存,二级缓存,三级缓存这里不准备过多描述相关知识点,相关内容我也准备写一篇文章,但不是现在)

image.png

关于代码部分请直接移步 github.com/598572/xzll…

这里直接把控制台输出拿过来

  • 注意 从输出先后顺序可以看出这些扩展点的调用时机
/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/bin/java -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=53897:/Applications/IntelliJ IDEA.app/Contents/bin -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 -classpath /Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/openjdk-8.jdk/Contents/Home/lib/tools.jar:/Users/hzz/myself_project/xzll/study-admin/study-admin-service/target/classes:/Users/hzz/.m2/repository/org/mybatis/spring/boot/mybatis-spring-boot-starter/2.1.4/mybatis-spring-boot-starter-2.1.4.jar:/Users/hzz/.m2/repository/org/springframework/boot/spring-boot-starter/2.1.13.RELEASE/spring-boot-starter-2.1.13.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/boot/spring-boot/2.1.13.RELEASE/spring-boot-2.1.13.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.1.13.RELEASE/spring-boot-starter-logging-2.1.13.RELEASE.jar:/Users/hzz/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:/Users/hzz/.m2/repository/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:/Users/hzz/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.11.2/log4j-to-slf4j-2.11.2.jar:/Users/hzz/.m2/repository/org/apache/logging/log4j/log4j-api/2.11.2/log4j-api-2.11.2.jar:/Users/hzz/.m2/repository/org/slf4j/jul-to-slf4j/1.7.30/jul-to-slf4j-1.7.30.jar:/Users/hzz/.m2/repository/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar:/Users/hzz/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/2.1.13.RELEASE/spring-boot-starter-jdbc-2.1.13.RELEASE.jar:/Users/hzz/.m2/repository/com/zaxxer/HikariCP/3.2.0/HikariCP-3.2.0.jar:/Users/hzz/.m2/repository/org/springframework/spring-jdbc/5.1.9.RELEASE/spring-jdbc-5.1.9.RELEASE.jar:/Users/hzz/.m2/repository/org/mybatis/spring/boot/mybatis-spring-boot-autoconfigure/2.1.4/mybatis-spring-boot-autoconfigure-2.1.4.jar:/Users/hzz/.m2/repository/org/mybatis/mybatis/3.5.6/mybatis-3.5.6.jar:/Users/hzz/.m2/repository/org/mybatis/mybatis-spring/2.0.6/mybatis-spring-2.0.6.jar:/Users/hzz/.m2/repository/mysql/mysql-connector-java/8.0.23/mysql-connector-java-8.0.23.jar:/Users/hzz/.m2/repository/com/github/pagehelper/pagehelper-spring-boot-starter/1.3.0/pagehelper-spring-boot-starter-1.3.0.jar:/Users/hzz/.m2/repository/com/github/pagehelper/pagehelper-spring-boot-autoconfigure/1.3.0/pagehelper-spring-boot-autoconfigure-1.3.0.jar:/Users/hzz/.m2/repository/com/github/pagehelper/pagehelper/5.2.0/pagehelper-5.2.0.jar:/Users/hzz/.m2/repository/com/github/jsqlparser/jsqlparser/3.2/jsqlparser-3.2.jar:/Users/hzz/.m2/repository/com/baomidou/mybatis-plus-boot-starter/3.4.3.1/mybatis-plus-boot-starter-3.4.3.1.jar:/Users/hzz/.m2/repository/com/baomidou/mybatis-plus/3.4.3.1/mybatis-plus-3.4.3.1.jar:/Users/hzz/.m2/repository/com/baomidou/mybatis-plus-extension/3.4.3.1/mybatis-plus-extension-3.4.3.1.jar:/Users/hzz/.m2/repository/com/baomidou/mybatis-plus-core/3.4.3.1/mybatis-plus-core-3.4.3.1.jar:/Users/hzz/.m2/repository/com/baomidou/mybatis-plus-annotation/3.4.3.1/mybatis-plus-annotation-3.4.3.1.jar:/Users/hzz/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.1.13.RELEASE/spring-boot-autoconfigure-2.1.13.RELEASE.jar:/Users/hzz/myself_project/xzll/study-common/target/classes:/Users/hzz/.m2/repository/org/springframework/boot/spring-boot-starter-aop/2.1.13.RELEASE/spring-boot-starter-aop-2.1.13.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/spring-aop/5.1.9.RELEASE/spring-aop-5.1.9.RELEASE.jar:/Users/hzz/.m2/repository/org/aspectj/aspectjweaver/1.9.5/aspectjweaver-1.9.5.jar:/Users/hzz/myself_project/xzll/study-admin/study-admin-api/target/classes:/Users/hzz/.m2/repository/org/springframework/cloud/spring-cloud-starter-openfeign/2.1.5.RELEASE/spring-cloud-starter-openfeign-2.1.5.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/cloud/spring-cloud-openfeign-core/2.1.5.RELEASE/spring-cloud-openfeign-core-2.1.5.RELEASE.jar:/Users/hzz/.m2/repository/io/github/openfeign/form/feign-form-spring/3.8.0/feign-form-spring-3.8.0.jar:/Users/hzz/.m2/repository/io/github/openfeign/form/feign-form/3.8.0/feign-form-3.8.0.jar:/Users/hzz/.m2/repository/io/github/openfeign/feign-core/10.4.0/feign-core-10.4.0.jar:/Users/hzz/.m2/repository/io/github/openfeign/feign-slf4j/10.4.0/feign-slf4j-10.4.0.jar:/Users/hzz/.m2/repository/io/github/openfeign/feign-hystrix/10.4.0/feign-hystrix-10.4.0.jar:/Users/hzz/myself_project/xzll/study-starter/util/target/classes:/Users/hzz/myself_project/xzll/study-starter/pay/target/classes:/Users/hzz/.m2/repository/org/springframework/boot/spring-boot-starter-websocket/2.1.13.RELEASE/spring-boot-starter-websocket-2.1.13.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/spring-messaging/5.1.9.RELEASE/spring-messaging-5.1.9.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/spring-beans/5.1.9.RELEASE/spring-beans-5.1.9.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/spring-websocket/5.1.9.RELEASE/spring-websocket-5.1.9.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/spring-context/5.1.9.RELEASE/spring-context-5.1.9.RELEASE.jar:/Users/hzz/.m2/repository/com/alibaba/cloud/spring-cloud-starter-alibaba-nacos-config/2.1.4.RELEASE/spring-cloud-starter-alibaba-nacos-config-2.1.4.RELEASE.jar:/Users/hzz/.m2/repository/com/alibaba/spring/spring-context-support/1.0.10/spring-context-support-1.0.10.jar:/Users/hzz/.m2/repository/com/alibaba/nacos/nacos-client/1.4.1/nacos-client-1.4.1.jar:/Users/hzz/.m2/repository/com/alibaba/nacos/nacos-common/1.4.1/nacos-common-1.4.1.jar:/Users/hzz/.m2/repository/org/apache/httpcomponents/httpasyncclient/4.1.4/httpasyncclient-4.1.4.jar:/Users/hzz/.m2/repository/org/apache/httpcomponents/httpcore/4.4.13/httpcore-4.4.13.jar:/Users/hzz/.m2/repository/org/apache/httpcomponents/httpcore-nio/4.4.13/httpcore-nio-4.4.13.jar:/Users/hzz/.m2/repository/com/alibaba/nacos/nacos-api/1.4.1/nacos-api-1.4.1.jar:/Users/hzz/.m2/repository/io/prometheus/simpleclient/0.5.0/simpleclient-0.5.0.jar:/Users/hzz/.m2/repository/org/springframework/cloud/spring-cloud-commons/2.1.6.RELEASE/spring-cloud-commons-2.1.6.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/security/spring-security-crypto/5.1.6.RELEASE/spring-security-crypto-5.1.6.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/cloud/spring-cloud-context/2.1.6.RELEASE/spring-cloud-context-2.1.6.RELEASE.jar:/Users/hzz/.m2/repository/com/alibaba/cloud/spring-cloud-starter-alibaba-nacos-discovery/2.1.4.RELEASE/spring-cloud-starter-alibaba-nacos-discovery-2.1.4.RELEASE.jar:/Users/hzz/.m2/repository/com/alibaba/cloud/spring-cloud-alibaba-commons/2.1.4.RELEASE/spring-cloud-alibaba-commons-2.1.4.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/cloud/spring-cloud-starter-netflix-ribbon/2.1.5.RELEASE/spring-cloud-starter-netflix-ribbon-2.1.5.RELEASE.jar:/Users/hzz/.m2/repository/com/netflix/ribbon/ribbon/2.3.0/ribbon-2.3.0.jar:/Users/hzz/.m2/repository/com/netflix/ribbon/ribbon-transport/2.3.0/ribbon-transport-2.3.0.jar:/Users/hzz/.m2/repository/io/reactivex/rxnetty-contexts/0.4.9/rxnetty-contexts-0.4.9.jar:/Users/hzz/.m2/repository/io/reactivex/rxnetty-servo/0.4.9/rxnetty-servo-0.4.9.jar:/Users/hzz/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar:/Users/hzz/.m2/repository/io/reactivex/rxnetty/0.4.9/rxnetty-0.4.9.jar:/Users/hzz/.m2/repository/com/netflix/ribbon/ribbon-core/2.3.0/ribbon-core-2.3.0.jar:/Users/hzz/.m2/repository/com/netflix/ribbon/ribbon-httpclient/2.3.0/ribbon-httpclient-2.3.0.jar:/Users/hzz/.m2/repository/org/apache/httpcomponents/httpclient/4.5.11/httpclient-4.5.11.jar:/Users/hzz/.m2/repository/com/sun/jersey/jersey-client/1.19.1/jersey-client-1.19.1.jar:/Users/hzz/.m2/repository/com/sun/jersey/jersey-core/1.19.1/jersey-core-1.19.1.jar:/Users/hzz/.m2/repository/javax/ws/rs/jsr311-api/1.1.1/jsr311-api-1.1.1.jar:/Users/hzz/.m2/repository/com/sun/jersey/contribs/jersey-apache-client4/1.19.1/jersey-apache-client4-1.19.1.jar:/Users/hzz/.m2/repository/com/netflix/servo/servo-core/0.12.21/servo-core-0.12.21.jar:/Users/hzz/.m2/repository/com/netflix/netflix-commons/netflix-commons-util/0.3.0/netflix-commons-util-0.3.0.jar:/Users/hzz/.m2/repository/com/netflix/ribbon/ribbon-loadbalancer/2.3.0/ribbon-loadbalancer-2.3.0.jar:/Users/hzz/.m2/repository/com/netflix/netflix-commons/netflix-statistics/0.1.1/netflix-statistics-0.1.1.jar:/Users/hzz/.m2/repository/io/reactivex/rxjava/1.3.8/rxjava-1.3.8.jar:/Users/hzz/.m2/repository/org/springframework/cloud/spring-cloud-starter-netflix-hystrix/2.1.5.RELEASE/spring-cloud-starter-netflix-hystrix-2.1.5.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/cloud/spring-cloud-starter/2.1.6.RELEASE/spring-cloud-starter-2.1.6.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/security/spring-security-rsa/1.0.9.RELEASE/spring-security-rsa-1.0.9.RELEASE.jar:/Users/hzz/.m2/repository/org/bouncycastle/bcpkix-jdk15on/1.64/bcpkix-jdk15on-1.64.jar:/Users/hzz/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.64/bcprov-jdk15on-1.64.jar:/Users/hzz/.m2/repository/org/springframework/cloud/spring-cloud-netflix-hystrix/2.1.5.RELEASE/spring-cloud-netflix-hystrix-2.1.5.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/cloud/spring-cloud-netflix-ribbon/2.1.5.RELEASE/spring-cloud-netflix-ribbon-2.1.5.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/cloud/spring-cloud-netflix-archaius/2.1.5.RELEASE/spring-cloud-netflix-archaius-2.1.5.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/cloud/spring-cloud-starter-netflix-archaius/2.1.5.RELEASE/spring-cloud-starter-netflix-archaius-2.1.5.RELEASE.jar:/Users/hzz/.m2/repository/com/netflix/archaius/archaius-core/0.7.6/archaius-core-0.7.6.jar:/Users/hzz/.m2/repository/com/google/code/findbugs/jsr305/3.0.1/jsr305-3.0.1.jar:/Users/hzz/.m2/repository/commons-configuration/commons-configuration/1.8/commons-configuration-1.8.jar:/Users/hzz/.m2/repository/com/netflix/hystrix/hystrix-core/1.5.18/hystrix-core-1.5.18.jar:/Users/hzz/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.9/HdrHistogram-2.1.9.jar:/Users/hzz/.m2/repository/com/netflix/hystrix/hystrix-serialization/1.5.18/hystrix-serialization-1.5.18.jar:/Users/hzz/.m2/repository/com/fasterxml/jackson/module/jackson-module-afterburner/2.9.9/jackson-module-afterburner-2.9.9.jar:/Users/hzz/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.9.0/jackson-annotations-2.9.0.jar:/Users/hzz/.m2/repository/com/netflix/hystrix/hystrix-metrics-event-stream/1.5.18/hystrix-metrics-event-stream-1.5.18.jar:/Users/hzz/.m2/repository/com/netflix/hystrix/hystrix-javanica/1.5.18/hystrix-javanica-1.5.18.jar:/Users/hzz/.m2/repository/org/ow2/asm/asm/5.0.4/asm-5.0.4.jar:/Users/hzz/.m2/repository/io/reactivex/rxjava-reactive-streams/1.2.1/rxjava-reactive-streams-1.2.1.jar:/Users/hzz/.m2/repository/org/reactivestreams/reactive-streams/1.0.3/reactive-streams-1.0.3.jar:/Users/hzz/.m2/repository/commons-cli/commons-cli/1.4/commons-cli-1.4.jar:/Users/hzz/.m2/repository/org/redisson/redisson/3.16.0/redisson-3.16.0.jar:/Users/hzz/.m2/repository/io/netty/netty-common/4.1.38.Final/netty-common-4.1.38.Final.jar:/Users/hzz/.m2/repository/io/netty/netty-codec/4.1.38.Final/netty-codec-4.1.38.Final.jar:/Users/hzz/.m2/repository/io/netty/netty-buffer/4.1.38.Final/netty-buffer-4.1.38.Final.jar:/Users/hzz/.m2/repository/io/netty/netty-transport/4.1.38.Final/netty-transport-4.1.38.Final.jar:/Users/hzz/.m2/repository/io/netty/netty-resolver/4.1.38.Final/netty-resolver-4.1.38.Final.jar:/Users/hzz/.m2/repository/io/netty/netty-resolver-dns/4.1.38.Final/netty-resolver-dns-4.1.38.Final.jar:/Users/hzz/.m2/repository/io/netty/netty-codec-dns/4.1.38.Final/netty-codec-dns-4.1.38.Final.jar:/Users/hzz/.m2/repository/io/netty/netty-handler/4.1.38.Final/netty-handler-4.1.38.Final.jar:/Users/hzz/.m2/repository/javax/cache/cache-api/1.1.1/cache-api-1.1.1.jar:/Users/hzz/.m2/repository/io/projectreactor/reactor-core/3.2.11.RELEASE/reactor-core-3.2.11.RELEASE.jar:/Users/hzz/.m2/repository/io/reactivex/rxjava3/rxjava/3.0.12/rxjava-3.0.12.jar:/Users/hzz/.m2/repository/org/jboss/marshalling/jboss-marshalling-river/2.0.11.Final/jboss-marshalling-river-2.0.11.Final.jar:/Users/hzz/.m2/repository/org/jboss/marshalling/jboss-marshalling/2.0.11.Final/jboss-marshalling-2.0.11.Final.jar:/Users/hzz/.m2/repository/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar:/Users/hzz/.m2/repository/org/yaml/snakeyaml/1.23/snakeyaml-1.23.jar:/Users/hzz/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-yaml/2.9.9/jackson-dataformat-yaml-2.9.9.jar:/Users/hzz/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.9.9/jackson-core-2.9.9.jar:/Users/hzz/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.9.9/jackson-databind-2.9.9.jar:/Users/hzz/.m2/repository/net/bytebuddy/byte-buddy/1.9.16/byte-buddy-1.9.16.jar:/Users/hzz/.m2/repository/org/jodd/jodd-bean/5.1.6/jodd-bean-5.1.6.jar:/Users/hzz/.m2/repository/org/jodd/jodd-core/5.1.6/jodd-core-5.1.6.jar:/Users/hzz/.m2/repository/io/springfox/springfox-swagger2/2.9.2/springfox-swagger2-2.9.2.jar:/Users/hzz/.m2/repository/io/swagger/swagger-annotations/1.5.20/swagger-annotations-1.5.20.jar:/Users/hzz/.m2/repository/io/swagger/swagger-models/1.5.20/swagger-models-1.5.20.jar:/Users/hzz/.m2/repository/io/springfox/springfox-spi/2.9.2/springfox-spi-2.9.2.jar:/Users/hzz/.m2/repository/io/springfox/springfox-core/2.9.2/springfox-core-2.9.2.jar:/Users/hzz/.m2/repository/io/springfox/springfox-schema/2.9.2/springfox-schema-2.9.2.jar:/Users/hzz/.m2/repository/io/springfox/springfox-swagger-common/2.9.2/springfox-swagger-common-2.9.2.jar:/Users/hzz/.m2/repository/io/springfox/springfox-spring-web/2.9.2/springfox-spring-web-2.9.2.jar:/Users/hzz/.m2/repository/com/fasterxml/classmate/1.4.0/classmate-1.4.0.jar:/Users/hzz/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/plugin/spring-plugin-metadata/1.2.0.RELEASE/spring-plugin-metadata-1.2.0.RELEASE.jar:/Users/hzz/.m2/repository/org/mapstruct/mapstruct/1.2.0.Final/mapstruct-1.2.0.Final.jar:/Users/hzz/.m2/repository/io/springfox/springfox-swagger-ui/2.9.2/springfox-swagger-ui-2.9.2.jar:/Users/hzz/.m2/repository/com/google/guava/guava/20.0/guava-20.0.jar:/Users/hzz/.m2/repository/com/alibaba/druid/1.1.18/druid-1.1.18.jar:/Users/hzz/.m2/repository/org/freemarker/freemarker/2.3.30/freemarker-2.3.30.jar:/Users/hzz/.m2/repository/com/alibaba/easyexcel/2.2.6/easyexcel-2.2.6.jar:/Users/hzz/.m2/repository/org/apache/poi/poi/3.17/poi-3.17.jar:/Users/hzz/.m2/repository/org/apache/commons/commons-collections4/4.1/commons-collections4-4.1.jar:/Users/hzz/.m2/repository/org/apache/poi/poi-ooxml/3.17/poi-ooxml-3.17.jar:/Users/hzz/.m2/repository/com/github/virtuald/curvesapi/1.04/curvesapi-1.04.jar:/Users/hzz/.m2/repository/org/apache/poi/poi-ooxml-schemas/3.17/poi-ooxml-schemas-3.17.jar:/Users/hzz/.m2/repository/org/apache/xmlbeans/xmlbeans/2.6.0/xmlbeans-2.6.0.jar:/Users/hzz/.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar:/Users/hzz/.m2/repository/cglib/cglib/3.1/cglib-3.1.jar:/Users/hzz/.m2/repository/org/ehcache/ehcache/3.6.3/ehcache-3.6.3.jar:/Users/hzz/.m2/repository/org/springframework/boot/spring-boot-starter-web/2.1.13.RELEASE/spring-boot-starter-web-2.1.13.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/boot/spring-boot-starter-json/2.1.13.RELEASE/spring-boot-starter-json-2.1.13.RELEASE.jar:/Users/hzz/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.9.9/jackson-datatype-jdk8-2.9.9.jar:/Users/hzz/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.9.9/jackson-datatype-jsr310-2.9.9.jar:/Users/hzz/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.9.9/jackson-module-parameter-names-2.9.9.jar:/Users/hzz/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.1.13.RELEASE/spring-boot-starter-tomcat-2.1.13.RELEASE.jar:/Users/hzz/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.31/tomcat-embed-core-9.0.31.jar:/Users/hzz/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.31/tomcat-embed-el-9.0.31.jar:/Users/hzz/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.31/tomcat-embed-websocket-9.0.31.jar:/Users/hzz/.m2/repository/org/hibernate/validator/hibernate-validator/6.0.18.Final/hibernate-validator-6.0.18.Final.jar:/Users/hzz/.m2/repository/javax/validation/validation-api/2.0.1.Final/validation-api-2.0.1.Final.jar:/Users/hzz/.m2/repository/org/jboss/logging/jboss-logging/3.3.3.Final/jboss-logging-3.3.3.Final.jar:/Users/hzz/.m2/repository/org/springframework/spring-web/5.1.9.RELEASE/spring-web-5.1.9.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/spring-webmvc/5.1.9.RELEASE/spring-webmvc-5.1.9.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/spring-expression/5.1.9.RELEASE/spring-expression-5.1.9.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/spring-core/5.1.14.RELEASE/spring-core-5.1.14.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/spring-jcl/5.1.9.RELEASE/spring-jcl-5.1.9.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/boot/spring-boot-starter-data-redis/2.1.13.RELEASE/spring-boot-starter-data-redis-2.1.13.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/data/spring-data-redis/2.1.10.RELEASE/spring-data-redis-2.1.10.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/data/spring-data-keyvalue/2.1.10.RELEASE/spring-data-keyvalue-2.1.10.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/data/spring-data-commons/2.1.10.RELEASE/spring-data-commons-2.1.10.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/spring-tx/5.1.9.RELEASE/spring-tx-5.1.9.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/spring-oxm/5.1.9.RELEASE/spring-oxm-5.1.9.RELEASE.jar:/Users/hzz/.m2/repository/org/springframework/spring-context-support/5.1.9.RELEASE/spring-context-support-5.1.9.RELEASE.jar:/Users/hzz/.m2/repository/io/lettuce/lettuce-core/5.1.8.RELEASE/lettuce-core-5.1.8.RELEASE.jar:/Users/hzz/.m2/repository/org/projectlombok/lombok/1.18.0/lombok-1.18.0.jar:/Users/hzz/.m2/repository/cn/hutool/hutool-all/5.6.6/hutool-all-5.6.6.jar:/Users/hzz/.m2/repository/com/alibaba/fastjson/1.2.46/fastjson-1.2.46.jar:/Users/hzz/.m2/repository/commons-fileupload/commons-fileupload/1.3.1/commons-fileupload-1.3.1.jar:/Users/hzz/.m2/repository/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar:/Users/hzz/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar:/Users/hzz/.m2/repository/commons-codec/commons-codec/1.7/commons-codec-1.7.jar:/Users/hzz/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar:/Users/hzz/.m2/repository/commons-collections/commons-collections/3.2/commons-collections-3.2.jar:/Users/hzz/.m2/repository/commons-net/commons-net/3.0/commons-net-3.0.jar:/Users/hzz/.m2/repository/org/apache/commons/commons-math3/3.2/commons-math3-3.2.jar:/Users/hzz/.m2/repository/commons-validator/commons-validator/1.4.0/commons-validator-1.4.0.jar:/Users/hzz/.m2/repository/commons-digester/commons-digester/1.8/commons-digester-1.8.jar:/Users/hzz/.m2/repository/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar:/Users/hzz/.m2/repository/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4.jar:/Users/hzz/.m2/repository/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar:/Users/hzz/.m2/repository/commons-pool/commons-pool/1.6/commons-pool-1.6.jar:/Users/hzz/.m2/repository/commons-io/commons-io/2.9.0/commons-io-2.9.0.jar:/Users/hzz/.m2/repository/org/apache/rocketmq/rocketmq-client/4.5.0/rocketmq-client-4.5.0.jar:/Users/hzz/.m2/repository/org/apache/rocketmq/rocketmq-common/4.5.0/rocketmq-common-4.5.0.jar:/Users/hzz/.m2/repository/org/apache/rocketmq/rocketmq-remoting/4.5.0/rocketmq-remoting-4.5.0.jar:/Users/hzz/.m2/repository/org/apache/rocketmq/rocketmq-logging/4.5.0/rocketmq-logging-4.5.0.jar:/Users/hzz/.m2/repository/io/netty/netty-tcnative-boringssl-static/2.0.29.Final/netty-tcnative-boringssl-static-2.0.29.Final.jar:/Users/hzz/.m2/repository/org/apache/commons/commons-lang3/3.8.1/commons-lang3-3.8.1.jar:/Users/hzz/.m2/repository/io/netty/netty-all/4.1.34.Final/netty-all-4.1.34.Final.jar com.xzll.test.StudyTestApplication

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::       (v2.1.13.RELEASE)

2021-08-24 10:59:55.542  INFO 26950 --- [           main] c.a.n.c.c.impl.LocalConfigInfoProcessor  : LOCAL_SNAPSHOT_PATH:/Users/hzz/nacos/config
2021-08-24 10:59:55.569  INFO 26950 --- [           main] c.a.nacos.client.config.impl.Limiter     : limitTime:5.0
2021-08-24 10:59:55.595  INFO 26950 --- [           main] c.a.nacos.client.config.utils.JvmUtil    : isMultiInstance:false
2021-08-24 10:59:55.611  WARN 26950 --- [           main] c.a.c.n.c.NacosPropertySourceBuilder     : Ignore the empty nacos configuration and get it based on dataId[study-admin-dev.properties] & group[study-admin]
2021-08-24 10:59:55.617  WARN 26950 --- [           main] c.a.c.n.c.NacosPropertySourceBuilder     : Ignore the empty nacos configuration and get it based on dataId[study-admin-dev-dev.properties] & group[study-admin]
2021-08-24 10:59:55.617  INFO 26950 --- [           main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-study-admin-dev-dev.properties,study-admin'}, BootstrapPropertySource {name='bootstrapProperties-study-admin-dev.properties,study-admin'}, BootstrapPropertySource {name='bootstrapProperties-study-admin-dev,study-admin'}]
------------ApplicationContextInitializerPoint # initialize 开始-------------
[ApplicationContextInitializer扩展点演示] # initialize:  org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@53fd0d10, started on Thu Jan 01 08:00:00 CST 1970, parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@293a5bf6
BeanDefinitionCount count: 5
org.springframework.context.annotation.internalConfigurationAnnotationProcessor
org.springframework.context.annotation.internalAutowiredAnnotationProcessor
org.springframework.context.annotation.internalCommonAnnotationProcessor
org.springframework.context.event.internalEventListenerProcessor
org.springframework.context.event.internalEventListenerFactory
autoConfigurationReport
时机: run 方法中的 this.prepareContext(); 的时候
-------------ApplicationContextInitializerPoint # initialize 结束------------

2021-08-24 10:59:55.653  INFO 26950 --- [           main] com.xzll.test.StudyTestApplication       : The following profiles are active: dev
2021-08-24 10:59:56.395  INFO 26950 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2021-08-24 10:59:56.397  INFO 26950 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2021-08-24 10:59:56.424  INFO 26950 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 14ms. Found 0 repository interfaces.
-----------------------[BeanDefinitionRegistryPostProcessor扩展点演示] # postProcessBeanDefinitionRegistry 开始--------------------------------------
[BeanDefinitionRegistryPostProcessor扩展点演示] # postProcessBeanDefinitionRegistry
时机: refresh()的 this.invokeBeanFactoryPostProcessors(beanFactory); 方法中执行; 此时 bean的定义信息 都已经加载完毕 但是还没到实例化以及初始化阶段
-----------------------[BeanDefinitionRegistryPostProcessor扩展点演示] # postProcessBeanDefinitionRegistry 结束--------------------------------------

2021-08-24 10:59:56.613  INFO 26950 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=2ed4fa11-ed98-34ad-90e4-a628563a5b1a
-----------------------[BeanDefinitionRegistryPostProcessor扩展点演示] # postProcessBeanFactory 开始--------------------------------------
[BeanDefinitionRegistryPostProcessor扩展点演示] # postProcessBeanFactory
时机: refresh()的 this.invokeBeanFactoryPostProcessors(beanFactory); 方法中执行; 此时 bean的定义信息 都已经加载完毕 但是还没到实例化以及初始化阶段
-----------------------[BeanDefinitionRegistryPostProcessor扩展点演示] # postProcessBeanFactory 结束--------------------------------------

-----------------------[BeanFactoryPostProcessor扩展点演示] # postProcessBeanFactory 开始--------------------------------------
[BeanFactoryPostProcessor扩展点演示] # postProcessBeanFactory
时机: refresh()的 this.invokeBeanFactoryPostProcessors(beanFactory); 方法中执行; 此时 bean的定义信息 都已经加载完毕 但是还没到实例化以及初始化阶段
-----------------------[BeanFactoryPostProcessor扩展点演示] # postProcessBeanFactory 结束--------------------------------------

2021-08-24 10:59:56.696  INFO 26950 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$3f825871] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

################## BeanPostProcessPoint 的构造方法 ##################

2021-08-24 10:59:57.209  INFO 26950 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8081 (http)
2021-08-24 10:59:57.244  INFO 26950 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-08-24 10:59:57.245  INFO 26950 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.31]
2021-08-24 10:59:57.382  INFO 26950 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-08-24 10:59:57.382  INFO 26950 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1716 ms
 _ _   |_  _ _|_. ___ _ |    _ 
| | |\/|_)(_| | |_\  |_)||_|_\ 
     /               |         
                        3.4.3.1 

################## InitializingBeanPoint 的构造方法 ################## 

------------InitializingBeanPoint 实现 BeanNameAware # setBeanName 开始-------------
[InitializingBeanPoint 实现 BeanNameAware ]  扩展点演示 # setBeanName name: initializingBeanPoint
------------InitializingBeanPoint 实现 BeanNameAware # setBeanName 结束-------------

-----------------------[BeanPostProcessPoint]  扩展点演示 # postProcessBeforeInitialization  开始--------------------------------------
[BeanPostProcessPoint]  扩展点演示 # postProcessBeforeInitialization , crurrentBeanName: initializingBeanPoint
这里只有当bean是 InitializingBeanPoint 时候才打印 否则的话控制台要爆满了 根本看不清,另外也是为了好和BeanNameAware以及InitializingBean做比较 
时机 bean实例化后,初始化之前
-----------------------[BeanPostProcessPoint]  扩展点演示 # postProcessBeforeInitialization  结束--------------------------------------

-----------------------[InitializingBeanPoint]  扩展点演示 # afterPropertiesSet  开始--------------------------------------
[BeanNameAwarePoint] # afterPropertiesSet
时机: bean实例化后 AbstractAutowireCapableBeanFactory 类的 initializeBean方法 中的 invokeInitMethods(beanName, wrappedBean, mbd);
-----------------------[InitializingBeanPoint]  扩展点演示 # afterPropertiesSet  结束--------------------------------------

-----------------------[BeanPostProcessPoint]  扩展点演示 # postProcessAfterInitialization  开始--------------------------------------
[BeanPostProcessPoint]  扩展点演示 # postProcessAfterInitialization , crurrentBeanName: initializingBeanPoint
这里只有当bean是 InitializingBeanPoint 时候才打印 否则的话控制台要爆满了 根本看不清,另外也是为了好和BeanNameAware以及InitializingBean做比较 
时机 bean初始化后
-----------------------[BeanPostProcessPoint]  扩展点演示 # postProcessAfterInitialization  结束--------------------------------------


################## PostConstructPoint的构造方法 ################## 


-----------------------[PostConstructPoint]  扩展点演示 @PostConstruct 开始--------------------------------------
[PostConstructPoint执行时机演示]
-----------------------[PostConstructPoint]  扩展点演示 @PostConstruct 结束--------------------------------------

2021-08-24 11:00:13.728  INFO 26950 --- [           main] pertySourcedRequestMappingHandlerMapping : Mapped URL path [/v2/api-docs] onto method [public org.springframework.http.ResponseEntity<springfox.documentation.spring.web.json.Json> springfox.documentation.swagger2.web.Swagger2Controller.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest)]
2021-08-24 11:00:13.945  INFO 26950 --- [           main] org.redisson.Version                     : Redisson 3.16.0
2021-08-24 11:00:19.176  INFO 26950 --- [sson-netty-4-13] o.r.c.pool.MasterPubSubConnectionPool    : 1 connections initialized for 127.0.0.1/127.0.0.1:6379
2021-08-24 11:00:19.225  INFO 26950 --- [sson-netty-4-19] o.r.c.pool.MasterConnectionPool          : 24 connections initialized for 127.0.0.1/127.0.0.1:6379
2021-08-24 11:00:19.350  WARN 26950 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2021-08-24 11:00:19.350  INFO 26950 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2021-08-24 11:00:19.354  WARN 26950 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2021-08-24 11:00:19.354  INFO 26950 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2021-08-24 11:00:19.632  INFO 26950 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-08-24 11:00:19.889  INFO 26950 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 'Nacos-Watch-Task-Scheduler'
2021-08-24 11:00:20.335  WARN 26950 --- [           main] o.s.b.a.f.FreeMarkerAutoConfiguration    : Cannot find template location(s): [classpath:/templates/] (please add some templates, check your FreeMarker configuration, or set spring.freemarker.checkTemplateLocation=false)
2021-08-24 11:00:20.815  INFO 26950 --- [           main] com.alibaba.nacos.client.naming          : initializer namespace from System Property :null
2021-08-24 11:00:20.816  INFO 26950 --- [           main] com.alibaba.nacos.client.naming          : initializer namespace from System Environment :null
2021-08-24 11:00:20.816  INFO 26950 --- [           main] com.alibaba.nacos.client.naming          : initializer namespace from System Property :null
2021-08-24 11:00:25.923  INFO 26950 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2021-08-24 11:00:25.940  INFO 26950 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2021-08-24 11:00:26.098  INFO 26950 --- [           main] s.d.s.w.s.ApiListingReferenceScanner     : Scanning for api listing references
2021-08-24 11:00:26.225  INFO 26950 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8081 (http) with context path ''
2021-08-24 11:00:26.227  INFO 26950 --- [           main] com.alibaba.nacos.client.naming          : [BEAT] adding beat: BeatInfo{port=8081, ip='192.168.31.23', weight=1.0, serviceName='study-test@@study-admin', cluster='DEFAULT', metadata={preserved.register.source=SPRING_CLOUD}, scheduled=false, period=5000, stopped=false} to beat map.
2021-08-24 11:00:26.228  INFO 26950 --- [           main] com.alibaba.nacos.client.naming          : [REGISTER-SERVICE] 932a9da5-fdd6-4747-bc13-a3e97b089281 registering service study-test@@study-admin with instance: Instance{instanceId='null', ip='192.168.31.23', port=8081, weight=1.0, healthy=true, enabled=true, ephemeral=true, clusterName='DEFAULT', serviceName='null', metadata={preserved.register.source=SPRING_CLOUD}}
2021-08-24 11:00:26.235  INFO 26950 --- [           main] c.a.c.n.registry.NacosServiceRegistry    : nacos registry, study-test study-admin 192.168.31.23:8081 register finished
2021-08-24 11:00:26.240  INFO 26950 --- [           main] com.xzll.test.StudyTestApplication       : Started StudyTestApplication in 41.351 seconds (JVM running for 46.824)
-----------------------[ApplicationRunnerPoint]  扩展点演示 # run  开始--------------------------------------
[ApplicationRunnerPoint] # run ; 时机:此时已经刷新容器处于run方法的后半部分了 接下来run方法将发布running事件
-----------------------[ApplicationRunnerPoint]  扩展点演示 # run  结束--------------------------------------

-----------------------[CommandLineRunnerPoint]  扩展点演示 # run  开始--------------------------------------
[CommandLineRunnerPoint] # run ; 时机:此时已经刷新容器处于run方法的后半部分了 接下来run方法将发布running事件
-----------------------[CommandLineRunnerPoint]  扩展点演示 # run  结束--------------------------------------

2021-08-24 11:00:26.245  INFO 26950 --- [           main] c.a.n.client.config.impl.ClientWorker    : [fixed-127.0.0.1_8848-f407f750-961e-44f2-80d7-6983374ad1e0] [subscribe] study-admin-dev+study-admin+f407f750-961e-44f2-80d7-6983374ad1e0
2021-08-24 11:00:26.246  INFO 26950 --- [           main] c.a.nacos.client.config.impl.CacheData   : [fixed-127.0.0.1_8848-f407f750-961e-44f2-80d7-6983374ad1e0] [add-listener] ok, tenant=f407f750-961e-44f2-80d7-6983374ad1e0, dataId=study-admin-dev, group=study-admin, cnt=1
2021-08-24 11:00:26.246  INFO 26950 --- [           main] c.a.n.client.config.impl.ClientWorker    : [fixed-127.0.0.1_8848-f407f750-961e-44f2-80d7-6983374ad1e0] [subscribe] study-admin-dev.properties+study-admin+f407f750-961e-44f2-80d7-6983374ad1e0
2021-08-24 11:00:26.246  INFO 26950 --- [           main] c.a.nacos.client.config.impl.CacheData   : [fixed-127.0.0.1_8848-f407f750-961e-44f2-80d7-6983374ad1e0] [add-listener] ok, tenant=f407f750-961e-44f2-80d7-6983374ad1e0, dataId=study-admin-dev.properties, group=study-admin, cnt=1
2021-08-24 11:00:26.246  INFO 26950 --- [           main] c.a.n.client.config.impl.ClientWorker    : [fixed-127.0.0.1_8848-f407f750-961e-44f2-80d7-6983374ad1e0] [subscribe] study-admin-dev-dev.properties+study-admin+f407f750-961e-44f2-80d7-6983374ad1e0
2021-08-24 11:00:26.246  INFO 26950 --- [           main] c.a.nacos.client.config.impl.CacheData   : [fixed-127.0.0.1_8848-f407f750-961e-44f2-80d7-6983374ad1e0] [add-listener] ok, tenant=f407f750-961e-44f2-80d7-6983374ad1e0, dataId=study-admin-dev-dev.properties, group=study-admin, cnt=1
2021-08-24 11:00:26.445  INFO 26950 --- [g.push.receiver] com.alibaba.nacos.client.naming          : received push data: {"type":"dom","data":"{\"name\":\"study-test@@study-admin\",\"clusters\":\"DEFAULT\",\"cacheMillis\":10000,\"hosts\":[{\"instanceId\":\"192.168.31.23#8081#DEFAULT#study-test@@study-admin\",\"ip\":\"192.168.31.23\",\"port\":8081,\"weight\":1.0,\"healthy\":true,\"enabled\":true,\"ephemeral\":true,\"clusterName\":\"DEFAULT\",\"serviceName\":\"study-test@@study-admin\",\"metadata\":{\"preserved.register.source\":\"SPRING_CLOUD\"},\"instanceHeartBeatInterval\":5000,\"ipDeleteTimeout\":30000,\"instanceHeartBeatTimeOut\":15000}],\"lastRefTime\":1629774026443,\"checksum\":\"\",\"allIPs\":false,\"reachProtectionThreshold\":false,\"valid\":true}","lastRefTime":369116050320926} from /192.168.31.23
2021-08-24 11:00:26.459  INFO 26950 --- [g.push.receiver] com.alibaba.nacos.client.naming          : new ips(1) service: study-test@@study-admin@@DEFAULT -> [{"instanceId":"192.168.31.23#8081#DEFAULT#study-test@@study-admin","ip":"192.168.31.23","port":8081,"weight":1.0,"healthy":true,"enabled":true,"ephemeral":true,"clusterName":"DEFAULT","serviceName":"study-test@@study-admin","metadata":{"preserved.register.source":"SPRING_CLOUD"},"instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000,"ipDeleteTimeout":30000}]
2021-08-24 11:00:26.466  INFO 26950 --- [g.push.receiver] com.alibaba.nacos.client.naming          : current ips:(1) service: study-test@@study-admin@@DEFAULT -> [{"instanceId":"192.168.31.23#8081#DEFAULT#study-test@@study-admin","ip":"192.168.31.23","port":8081,"weight":1.0,"healthy":true,"enabled":true,"ephemeral":true,"clusterName":"DEFAULT","serviceName":"study-test@@study-admin","metadata":{"preserved.register.source":"SPRING_CLOUD"},"instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000,"ipDeleteTimeout":30000}]

本文完~~~