日期:2014-05-18  浏览次数:20826 次

spring注入不了对象、报空指针异常
spring配置文件
<!-- sessionfactory配置 -->
     <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="configLocation">
      <value>classpath:hibernate.cfg.xml</value>
      </property>
     </bean>
     
    <!-- txManager配置 -->
     <bean id="txManage" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
      <property name="sessionFactory" ref="sessionFactory"></property>
     </bean>
     
     <!-- 定义事务通知 -->
     <tx:advice id="txAdvice" transaction-manager="txManage">
      <tx:attributes>
      <tx:method name="*" propagation="REQUIRED"/>
      </tx:attributes> 
     </tx:advice>
     
     <aop:config>
      <aop:pointcut expression="execution(* com.ywt.dao..*.*(..))" id="serverMethod"/>
      <aop:advisor advice-ref="txAdvice" pointcut-ref="serverMethod"/>
     </aop:config>
     
     <!-- 实体bean -->
     <bean id="detailbean" class="com.ywt.bean.Bug_detail"></bean>
     <bean id="projectbean" class="com.ywt.bean.Bug_project"></bean>
     
     
      <!-- dao层 -->
<bean id="detailDaoImpl" class="com.ywt.dao.impl.Bug_detailDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="projectDaoImpl" class="com.ywt.dao.impl.Bug_projectDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>

<!-- service层 -->
<bean id="detailServiceDaoimpl" class="com.ywt.service.impl.Bug_detailServiceImpl">
<property name="detailDao" ref="detailDaoImpl"></property>
</bean>
<bean id="projectServiceDaoimpl" class="com.ywt.service.impl.Bug_projectServiceImpl">
<property name="projectDao" ref="projectDaoImpl"></property>
</bean>


<!-- ActionBean -->
<bean id="bug_detailAction" class="com.ywt.web.action.Bug_detailAction">
<property name="bug_detailService" ref="detailServiceDaoimpl"></property>
<property name="bug_projectService" ref="projectServiceDaoimpl"></property>
</bean>
     

action代码
package com.ywt.web.action;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.ywt.bean.Bug_de