IocBean可否延迟加载?在引用的时候才执行create="init" init方法
4 回复
代码1 TaskMainLauncher
@IocBean(create = "init")
public class TaskMainLauncher {
@Inject("refer:$ioc")
private Ioc ioc;
@Inject
@Reference
QuartzJobService quartzJobService;
public static void main(String[] args) {
new NbApp().run();
}
public void init() {
System.out.println("1");
/**
* 初始化定时任务
*/
ioc.get(NutQuartzCronJobFactory.class);
}
}
代码2
@IocBean(create = "init")
public class NutQuartzCronJobFactory {
@Inject
@Reference
protected QuartzJobService quartzJobService;
public void init() throws Exception {
System.out.println("2");
}
输出结果为 :2 1
添加回复
请先登陆