ssh项目运行到action中的service时报null异常,打印service也是null,这个问题是spring的配置文件中没有配置好,在ApplicationContext.xml中配置:
<bean id="vipDao" class="com.ssh.im2010.dao.impl.VipDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="vipService" class="com.ssh.im2010.service.impl.VipServiceImpl">
<property name="vipDao" ref="vipDao"></property>
</bean>
<bean id="vipAction" class="com.ssh.im2010.action.VipAction"
scope="prototype">
<property name="vipService" ref="vipService"></property>
</bean>
即可。
另外:运行时报事务没有开启的错,有可能是hibernate管理着事务,将<property name="current_session_context_class">thread</property>注释掉即可。