java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()

使用spring,hibernate时,报错:

Caused by: java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/Session;
	at org.springframework.orm.hibernate4.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:412)
	... 34 more

 什么原因嗯?

项目使用maven构建:
java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()
 根本原因:hibernate版本不一致,3和4混着用了。

解决方法:因为我打算用hibernate4,所以去掉hibernate3的依赖

<dependency>
			<groupId>com.xxx</groupId>
			<artifactId>abc</artifactId>
			<version>0.2.8-SNAPSHOT</version>
			<exclusions>
				<exclusion>
					<groupId>org.hibernate</groupId>
					<artifactId>hibernate</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

 这样就排除了:

<groupId>org.hibernate</groupId>

<artifactId>hibernate</artifactId>

<version>3.2.6.ga</version>

 

参考:http://schy-hqh.iteye.com/blog/1950125

http://blog.csdn.net/selaginella/article/details/8799563

你可能感兴趣的:(spring,Hibernate,整合)