关于Spring 注解 空指针问题 跪求前辈帮忙啊
Action中:
@Service
@Scope("prototype")
public class LoginAction extends BaseAction{
private AdminInfo adminInfo;
private String errorMsg;
@Resource
private AdminInfoDao amdinInfoDao;
@Transactional(readOnly=true)
public String execute(){
AdminInfo a=amdinInfoDao.
findByAdminCodeAndPassword("admin","111111");
//此处amdinInfoDao报空指针异常
}
DAO中:
@Repository
public class AdminInfoDaoImpl extends BaseDao implements AdminInfoDao{
//BaseDao中已经配置了sessionFactory
@Override
public AdminInfo findByAdminCodeAndPassword(String adminCode,
String password) throws DaoException{...}
}
web.xml中:
有引入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>
<filter>
<filter-name>
openSessionInviewFilter
</filter-name>
<filterclass>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
</filter>
<filter>
<filter-name>Struts2</filter-name>
<filterclass> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>openSessionInviewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>Struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Spring配置文件中部分配置:
<!-- 开启注释扫描 -->
<context:component-scan base-package="org.pstt.hhhh">
</context:component-scan>
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<tx:annotation-driven proxy-target-class="true"
transaction manager="txManager"/>
<aop:config proxy-target-class="true">
<aop:pointcut id="pointcut" expression="within(org.pstt.hhhh.action..*)"/>
</aop:config>
</beans>
请问 amdinInfoDao为什么报空指针异常 哪里还没配置好
分享到:
[解决办法]
我现在也遇到了同样的问题,楼主解决了没?先Mark一下哈