各位大侠好:最近我搭了一个spring+struts+ibaits的框架,里面用到quartz,用于处理定时任务;但是项目启动的时候,不能加载对应的bean,就是applicationContext*.xml文件;项目启动的时候总是报空指针,我在想是不是项目没有加载applicationContext*.xml;求各位大侠帮忙看看;
;这是我的web.xml配置;
<!-- 配置Struts2 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 配置Spring -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
WEB-INF/classes/applicationContext*.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- 配置quartz -->
<servlet>
<servlet-name>QuartzInitializer</servlet-name>
<servlet-class>com.asiainfo.web.QuartzInitializerServlet</servlet-class>
<init-param>
<param-name>config-file</param-name>
<param-value>quartz.properties</param-value>
</init-param>
<init-param>
<param-name>shutdown-on-unload</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>10</load-on-startup>
</servlet>
applicationContext*.xml
<bean id="iSchedulerService" class="com.asiainfo.service.impl.SchedulerServiceImpl">
<property name="quartzTaskConfigDao" ref="quartzTaskConfigDao"/>
</bean>
引用classpath
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:applicationContext*.xml
</param-value>
</context-param>
或者引用绝对路径记得带/,你那个是相对路径了
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext*.xml
</param-value>
</context-param>
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。