leikai163 2010-03-10 14:43
浏览 363
已采纳

spring注入对象为null的问题

本人使用ssh2做一个接口,用两种方式实现,一种是从web页面上手动导入,一种用到了quartz技术,定时触发。写好了应用之后,第一种是没有问题,用第二种的时候每次作业调度业务逻辑层的时候,都提示注入的dao对象为空,折腾了两天也找不到原因在那里?请各位帮忙看看问题所在下面贴下关键代码。
service层是定义了一个接口,一个实现类,代码如下:[code="java"]public class QueryLYUserTableServiceImpl implements QueryLYUserTableService {

QueryLYUserTableDao dao1;
InsertPowerUserTableDao dao2;

public List queryInsertTable() {
// TODO Auto-generated method stub
return dao1.queryInsertTable();
}

public QueryLYUserTableDao getDao1() {
    return dao1;
}
public void setDao1(QueryLYUserTableDao dao1) {
    this.dao1 = dao1;
}
public InsertPowerUserTableDao getDao2() {
    return dao2;
}
public void setDao2(InsertPowerUserTableDao dao2) {
    this.dao2 = dao2;
}

}[/code]

applicationContext.xml如下:[code="java"] autowire="byName">




autowire="byName">



<bean id="service"  class="com.ly.dbInterface.manager.service.QueryLYUserTableServiceImpl" autowire="byName">
            <property name="dao1">
                <ref local="dao1" />
            </property>
            <property name="dao2">
                <ref local="dao2" />
            </property>
</bean>




               <bean name="simpleTriggerBean" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
                              <!--这里定义定时任务的对象的位置-->
                        <property name="jobDetail" ref="reportJbo"/>
                       <!--这里定义每六秒钟程序执行一次-->
                        <property name="repeatInterval" value="1200000"/>
                       <!--这里定义程序启动两秒钟后开始执行-->
                     <property name="startDelay" value="30000"/>
                </bean>
             <!--          启动任务    -->
               <bean name="schedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
                     <property name="triggers">
                         <list>
                              <ref bean="simpleTriggerBean"/>
                        </list>
                   </property>
              </bean>[/code]

请各位看看

  • 写回答

4条回答 默认 最新

  • iteye_15594 2010-03-12 15:11
    关注



    应该是:







    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?
  • ¥50 invest生境质量模块
  • ¥15 nhanes加权logistic回归,svyglm函数