我的情况是这样的,整个项目能正常启动,不会报错。但是调用action的时候出现空指针错误。
经过我debug发现。action中的service对象没初始化,service中的dao对象没初始化,dao中的sessionfactory美初始化。也就是说根上的原因是sessionfactory没能初始化。但是我已经把它配置在了spring的配置文件中。。。。。很奇怪。虽然我hibernate的所有配置都还放在hibernate.cfg.xml中,但是spring中已经能找到这个文件了,因为我的那些实体类都已经在数据库中生成对应的表。。。。请问怎么回事。。。
hibernate.cfg.xml 如下
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
oracle.jdbc.driver.OracleDriver
jdbc:oracle:thin:@127.0.0.1:1521:orcl
saber
saber520
10
org.hibernate.dialect.Oracle9iDialect
thread
org.hibernate.cache.NoCacheProvider
true
true
update
spring的context.xml 如下
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
classpath:hibernate.cfg.xml
</bean>
请帮忙。。。还需要晒什么。。。。。。请留言。