RT 也就是  dao没有注入成功   找了很久没找到原因 哪位高手帮小弟看看了  感激不尽了!!
用下面的单元侧类 测试时 可以正常的为 UserManager   注入 userDao
但是放在tomcat中  出现空指针错了  这是我的web.xml<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <!-- 指定spring的配置文件 -->
  <context-param>
   <param-name>contextConfigLocation</param-name>
   <param-value>classpath:applicationContext.xml</param-value>
  </context-param>
  
  <!-- 启动spring容器 -->
  <listener>
   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
   
  <!-- struts2的过滤器 -->
  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>
  <filter-mapping>
      <filter-name>struts2</filter-name>
      <url-pattern>/*</url-pattern>
  </filter-mapping>
</web-app>applicationContext.xml<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:aop="http://www.springframework.org/schema/aop"
     xmlns:tx="http://www.springframework.org/schema/tx"
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<!-- 配置SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>

<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>

<!-- 那些类那些方法使用事务-->
<aop:config>
<aop:pointcut id="allManagerMethod" expression="execution(* com.kejiansmallsite.manager.*.*(..))"/>
<aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice"/>
</aop:config> 

<!-- 事务的传播特性  -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="modify*" propagation="REQUIRED"/>
<tx:method name="find*" propagation="REQUIRED"/>
<tx:method name="*" propagation="REQUIRED" read-only="true"/>
</tx:attributes>
</tx:advice>
 
  <bean id="userManager" class="com.kejiansmallsite.manager.UserManagerImpl">
<property name="userDao" ref="userDao"/>
</bean>
          
<bean id="userDao" class="com.kejiansmallsite.dao.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>

<bean id="userRegisterAction" class="com.kejiansmallsite.action.UserRegisterAction">
<property name="userManager" ref="userManager"/>
</bean>
</beans>UserManagerImpl.javapackage com.kejiansmallsite.manager;import java.util.List;import com.kejiansmallsite.dao.UserDao;
import com.kejiansmallsite.dao.UserDaoImpl;
import com.kejiansmallsite.domain.Page;
import com.kejiansmallsite.domain.User;public class UserManagerImpl implements UserManager { private UserDao userDao; public void addUser(User user) {
userDao.addUser(user);
} public boolean checkUserNameExist(String username) {
if(userDao.findUserByUserName(username) != null){
return true;
}else{ 
return false;
}
} public boolean delete(int id, String powerType) {
// TODO Auto-generated method stub
return false;
} public Page doPage(int currentPage, int pageSize) {
// TODO Auto-generated method stub
return null;
} public User findUserByUserName(String username) {
// TODO Auto-generated method stub
return userDao.findUserByUserName(username);
} public List listUser() {
// TODO Auto-generated method stub
return null;
} public User userLogin(String name, String password) {
// TODO Auto-generated method stub
return null;
}

public void setUserDao(UserDao userDao) {
this.userDao = userDao;
} public UserDao getUserDao() {
return userDao;
}
}单元侧类UserManagerImplTestpackage com.kejiansmallsite.manager;
import junit.framework.TestCase;import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;import com.kejiansmallsite.domain.HomeAddress;
import com.kejiansmallsite.domain.User;public class UserManagerImplTest extends TestCase {

public void testfindUserByUserName(){
BeanFactory factory = new ClassPathXmlApplicationContext("applicationContext.xml");
UserManager userManager = (UserManager)factory.getBean("userManager");

User user = userManager.findUserByUserName("LiSi");
if (user != null){
System.out.println(user.getUsername());
}else{
System.out.println("找不到该人");
}


}
}