zoukankan      html  css  js  c++  java
  • Spring @Lazy

    @DependsOn用于强制初始化其他Bean。可以修饰Bean类或方法,使用该Annotation时可以指定一个字符串数组作为参数,每个数组元素对应于一个强制初始化的Bean。

    @DependsOn({"steelAxe","abc"})
    @Component
    public class Chinese implements Person{
       //codes here
    }

    @Lazy用于指定该Bean是否取消预初始化。主要用于修饰Spring Bean类,用于指定该Bean的预初始化行为,使用该Annotation时可以指定一个boolean型的value属性,该属性决定是否要预初始化该Bean。

    @Lazy(true)
    @Component
    public class Chinese implements Person{
       //codes here
    }

    啦啦啦

    Class : SpringDynamicCornTask

    复制代码
    package com.xindatai.ibs.lime.dycSchedul;
    

    import org.springframework.context.annotation.Lazy;
    import org.springframework.scheduling.annotation.EnableScheduling;
    import org.springframework.scheduling.annotation.SchedulingConfigurer;
    import org.springframework.scheduling.config.ScheduledTaskRegistrar;
    import org.springframework.stereotype.Component;

    @Lazy(false)
    @Component
    @EnableScheduling
    public class SpringDynamicCornTask implements SchedulingConfigurer {

    @Override
    </span><span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span><span style="color: #000000"> configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        </span><span style="color: #008000">//</span><span style="color: #008000"> TODO Auto-generated method stub</span>
    
    }

    }

    复制代码

    啦啦啦

  • 相关阅读:
    uniapp
    uniapp
    uniapp
    偶然发现的一天
    了不起的麦瑟尔夫人第三季
    女性长期没有"恩爱",会出现这4个后果?提醒:频率最好能在这个数
    IntelliJ IDEA live template 方法配置
    使用MHA实现MySQL主从复制高可用
    Linux 常用命令介绍
    开源堡垒机
  • 原文地址:https://www.cnblogs.com/jpfss/p/9429183.html
Copyright © 2011-2022 走看看