本人使用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]
请各位看看