spring mvc web应用启动时就执行特定处理(线程启动)
Posted kaschie
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring mvc web应用启动时就执行特定处理(线程启动)相关的知识,希望对你有一定的参考价值。
package com.sdt.platform.index.controller; import java.net.URL; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.annotation.Resource; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component; import com.sdt.base.util.HttpRequest; import com.sdt.common.pub.model.SerialCode; import com.sdt.platform.movie.model.MovieArea; import com.sdt.platform.movie.model.MovieDirector; import com.sdt.platform.movie.model.MoviePerformer; import com.sdt.platform.movie.model.MovieProducts; import com.sdt.platform.movie.model.MovieYears; import com.sdt.platform.movie.model.PerformerItem; import com.sdt.platform.movie.model.Synopsis; import com.sdt.platform.movie.service.MovieAreaService; import com.sdt.platform.movie.service.MovieDirectorService; import com.sdt.platform.movie.service.MoviePerformerService; import com.sdt.platform.movie.service.MovieProductsService; import com.sdt.platform.movie.service.MovieTypeService; import com.sdt.platform.movie.service.MovieYearsService; import com.sdt.platform.movie.service.PerformerItemService; import com.sdt.platform.movie.service.SynopsisService; import vbpm.utils.code.CodeGenerator; import java.net.URL; import java.util.List; import java.util.Timer; import java.util.TimerTask; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.hibernate.criterion.DetachedCriteria; import org.hibernate.criterion.Restrictions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.stereotype.Service; import com.sdt.base.util.HttpRequest; import com.sdt.common.pub.model.SerialCode; import com.sdt.platform.movie.model.MovieArea; import com.sdt.platform.movie.model.MovieDirector; import com.sdt.platform.movie.model.MoviePerformer; import com.sdt.platform.movie.model.MovieProducts; import com.sdt.platform.movie.model.MovieYears; import com.sdt.platform.movie.model.PerformerItem; import com.sdt.platform.movie.model.Synopsis; import java.net.URL; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.hibernate.criterion.DetachedCriteria; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import com.sdt.base.controller.JsonControllerSupport; import com.sdt.base.daosupport.Pagination; import com.sdt.base.util.HttpRequest; import com.sdt.common.pub.model.SerialCode; import com.sdt.platform.job.model.JobRelease; import com.sdt.platform.movie.model.ListPage; import com.sdt.platform.movie.model.MovieArea; import com.sdt.platform.movie.model.MovieDirector; import com.sdt.platform.movie.model.MoviePerformer; import com.sdt.platform.movie.model.MovieProducts; import com.sdt.platform.movie.model.MovieType; import com.sdt.platform.movie.model.MovieYears; import com.sdt.platform.movie.model.PerformerItem; import com.sdt.platform.movie.model.Synopsis; import com.sdt.platform.movie.service.MovieAreaService; import com.sdt.platform.movie.service.MovieDirectorService; import com.sdt.platform.movie.service.MoviePerformerService; import com.sdt.platform.movie.service.MovieProductsService; import com.sdt.platform.movie.service.MovieTypeService; import com.sdt.platform.movie.service.MovieYearsService; import com.sdt.platform.movie.service.PerformerItemService; import com.sdt.platform.movie.service.SynopsisService; import net.sf.json.JSONObject; import vbpm.utils.code.CodeGenerator; /** * spring mvc web应用启动时就执行特定处理 * * @author liuyajun * */ @Component public class Startuphtml implements ApplicationContextAware @Resource private MovieTypeService movieTypeService; @Resource private MovieAreaService movieAreaService; @Resource private MovieYearsService movieYearsService; @Resource private MovieProductsService movieProductsService; @Resource private MovieDirectorService movieDirectorService; @Resource private MoviePerformerService moviePerformerService; @Resource private PerformerItemService performerItemService; @Resource private SynopsisService synopsisService; @Resource private CodeGenerator codeGenerator; @Override public void setApplicationContext(ApplicationContext var1) throws BeansException // 调用线程 RunTask r = new RunTask(); r.start(); // 线程加载 class RunTask extends Thread public void run() Thread.sleep(50000); catch (Exception ex) ex.printStackTrace();
以上是关于spring mvc web应用启动时就执行特定处理(线程启动)的主要内容,如果未能解决你的问题,请参考以下文章