applicaitonContext属性未注入,请在applicationContext.xml中定义SpringContextHolder.
方法/步骤
1、我用擢爻充种的jeesite框架,在使用定时任务时,出现一些问题,,1.在windows上项目可以在tomcat下芟坳葩津,运行2.在linux下项目在tomcatgh下,却出现问题:15-Dec-201715:15:37.552INFO[www.toolcoo.com-startStop-1]org.apache.catalina.core.ApplicationContext.logInitializingSpringrootWebApplicationContext2017-12-1515:15:44,224ERROR[org.springframework.web.context.ContextLoader]-Contextinitializationfailedorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'tasksBean':Injectionofautowireddependenciesfailed;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Couldnotautowirefield:privatecom.chseeker.modules.information.service.ToolInformationServicecom.thinkgem.jeesite.modules.sys.init.TasksBean.informationService;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'toolInformationService':Injectionofautowireddependenciesfailed;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Couldnotautowirefield:privatecom.chseeker.modules.use.service.ToolUserInfoServicecom.chseeker.modules.information.service.ToolInformationService.toolUserInfoService;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'toolUserInfoService':Injectionofautowireddependenciesfailed;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Couldnotautowirefield:protectedcom.thinkgem.jeesite.common.persistence.CrudDaocom.thinkgem.jeesite.common.service.CrudService.dao;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'toolUserInfoDao':FactoryBeanthrewexceptiononobjectcreation;nestedexceptionis…………Causedby:java.lang.IllegalStateException:applicaitonContext属性未注入,请在applicationContext.xml中定义SpringContextHolder. atorg.apache.commons.lang3.Validate.validState(Validate.java:826) atcom.thinkgem.jeesite.common.utils.SpringContextHolder.assertContextInjected(SpringContextHolder.java:105) atcom.thinkgem.jeesite.common.utils.SpringContextHolder.getBean(SpringContextHolder.java:56) atcom.chseeker.modules.use.entity.ToolUserInfo.<clinit>(ToolUserInfo.java:26) ...75more
2、这个是因为,,applicaitonContext没有初始化,查看
3、发现,是通过注释加载的,,我就想,是不是,我的定时任务比springContextHolder加载的早,造成的呢?于是,,我在spring-context.xml中写入<beanclass="com.thinkgem.jeesite.common.utils.SpringContextHolder"lazy-init="false"/>
4、,最后发布到linux中,,启动,问题解决最后的最后,,为什么windows下可以,linux下不可以呢???