开发者社区> 问答> 正文

spring bean不加载问题??

a123456678 2016-03-16 15:25:58 1265
各位大侠好:最近我搭了一个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>
XML Java 数据格式 Spring
分享到
取消 提交回答
全部回答(1)
  • a123456678
    2019-07-17 19:04:01
    引用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>
    0 0

集结各类场景实战经验,助你开发运维畅行无忧

推荐文章
相似问题