当前位置:首页>财经>正文

web中有几种配置spring的方式 spring 怎么启动定时任务

2023-06-05 15:10:28 互联网 未知 财经

 web中有几种配置spring的方式 spring 怎么启动定时任务

web中有几种配置spring的方式

spring有三种启动方式,使用ContextLoaderServlet,ContextLoaderListener和ContextLoaderPlugIn
spring3.0及以后版本中已经删除ContextLoaderServlet 和Log4jConfigServlet
可以采用余下两种启动方式ContextLoaderListener和ContextLoaderPlugIn
建议使用ContextLoaderListener

N0:1





org.springframework.web.context.ContextLoaderListener




contextConfigLocation
/WEB-INF/applicationContext.xml


N0:2




context
org.springframework.web.context.ContextLoaderServlet
1
-->

N0:3




spring 怎么启动定时任务


<1>、在配置信息中SchedulerFactoryBean定义了多个触发器,在启动Spring后,就是从这个配置获取到触发器。

<2>、触发器是通过CronTriggerBean来配置,它设置了任务类和任务启动的时间

<3>、MethodInvokingJobDetailFactoryBean是任务类的配置,设置了执行任务的对象是那个Bean和需要执行这个Bean大那个方法。

spring加载容器有几种方法

如果你想在Spring容器完成bean的实例化、配置和其它的初始化后执行一些自定义逻辑,你可以插入一个或多个的BeanPostProcessor实现 Java代码 package scripting import org.springframework.beans.factory.config.BeanPostProcessor import org..