解决方案 »

  1.   

    用ssh还需要实例化对象吗?我定时器到指定时间开始运行的时候报错。主要是mailService为空,里面没值。会不会是延迟加载的问题
      

  2.   

     SendEmailJob 第22行空指针,应该是this.mailService.sendEmail();这行出现的
    原因是mailService是空,真正原因是Spring配置有问题,你在
        <bean id="quantzjobBean" class="org.springframework.scheduling.quartz.JobDetailBean">
          <property name="jobClass">
          <!-- 实现了org.springframework.scheduling.quartz.QuartzJobBean的JobBean -->
          <value>action.SendEmailJob</value>
          </property>
         </bean>
    中并没有声明要注入mailService
    <bean id="mailService" parent="baseTransactionProxy">
     <property name="target" ref="targetMailService" />
     </bean> 
     <bean id="targetMailService" class="service.impl.MailServiceImpl">
     <property name="sendEmailDao" ref="sendEmailDao" />
     </bean>具体怎么注入给你个例子,你看再看看就应该明白了
    <bean id="manyRiskInOneService" parent="abstractTxDefinition">
    <property name="target">
                <bean class="com.neusoft.soc.bigscreendisplay.manyriskinone.impl.ManyRiskInOneServiceImpl">
                 <property name="manyRiskInOneDAOImpl" ref="manyRiskInOneDAOImpl" />
                 <property name="manyRiskInOneThridPartyDAOImpl" ref="manyRiskInOneThirdPartyDAOImpl" />
                </bean> 
            </property>
    </bean>
      

  3.   

    不好意思,我明白你的意思,但能具体说说quartz的配置文件中怎么注入service吗?这例子不是很看得懂
      

  4.   

    谢谢。我已经解决了,在quartz的配置文件注入service就行了
      

  5.   

    我也注入service了,还是报空指针,你是怎么注入的,能贴一下代码么,求大神帮忙,不胜感激....
      

  6.   

    <bean id="jobOnFixedTime" class="org.springframework.scheduling.quartz.JobDetailBean">
      <property name="jobClass" value="cn.sh.ideal.sendmsg.JobSMSOnFixedTime"> 
      </property>
      <property name="jobDataAsMap">
      <map>
      <entry key="timeout" value="0"/>
      <entry key="jobService">
      <ref bean="jobService"/>
      </entry>

      </map>
      </property>
      </bean>