Spring 4.2.3.RELEASE和Hibernate 5.0.4.Final兼容性问题
有没有人一起配置Spring 4.2.3.RELEASE和Hibernate 5.0.4.Final? 来自Spring的官方文档说从版本4.2开始支持Hibernate版本5.但是如果将它们配置在一起我总是得到以下exception
Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.aop.framework.autoproxy.AutoProxyUtils.determineTargetClass(Lorg/springframework/beans/factory/config/ConfigurableListableBeanFactory;Ljava/lang/String;)Ljava/lang/Class; at org.springframework.context.event.EventListenerMethodProcessor.afterSingletonsInstantiated(EventListenerMethodProcessor.java:78) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:792) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:838) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83) at me.shafin.sustord.dao.App.main(App.java:8)
这是pom.xml
4.0.0 org.springframework.samples.service.service RokomiMoc 0.0.1-SNAPSHOT war 1.8 UTF-8 UTF-8 2.3.1 1.2 3.1.0 4.2.3.RELEASE 3.2.5.RELEASE 5.0.4.Final 5.0.1.Final 1.1.0.Final 1.3.1 1.0.13 1.7.5 4.11 1.8 1.8 org.springframework spring-core ${spring-framework.version} org.springframework spring-webmvc ${spring-framework.version} org.springframework spring-orm ${spring-framework.version} org.springframework spring-aspects ${spring-framework.version} org.springframework spring-expression ${spring-framework.version} org.springframework spring-aop ${spring-framework.version} org.springframework spring-context ${spring-framework.version} javax.servlet jstl ${jstl.version} javax.servlet.jsp javax.servlet.jsp-api ${jsp.version} org.springframework.security spring-security-core ${spring-security.version} org.springframework.security spring-security-config ${spring-security.version} org.springframework.security spring-security-web ${spring-security.version} org.springframework.security spring-security-taglibs ${spring-security.version} javax.validation validation-api ${javax.validation.version} org.hibernate hibernate-validator ${hibernate.validator.version} org.hibernate hibernate-core ${hibernate-framework.version} org.hibernate hibernate-entitymanager ${hibernate-framework.version} mysql mysql-connector-java 5.1.37 c3p0 c3p0 0.9.1.2 javax.transaction jta 1.1 jaxen jaxen 1.1.6 commons-fileupload commons-fileupload ${commons-fileupload.version} org.codehaus.jackson jackson-mapper-asl 1.9.13 javax.servlet javax.servlet-api ${servlet.version} org.slf4j slf4j-api ${slf4j.version} compile org.springframework spring-test ${spring-framework.version} test junit junit ${junit.version} test org.eclipse.persistence org.eclipse.persistence.jpa.modelgen.processor 2.5.2 provided javax.annotation jsr250-api 1.0 provided org.springframework spring-beans 4.2.3.RELEASE com.sun.mail javax.mail 1.5.4 javax.mail mail 1.4.7 org.springframework spring-context-support 4.2.3.RELEASE
使用Spring 4.0.6和Hibernate 4.3.6,这个pom.xml和我的其他配置都很好……任何人都可以分享他/她对这些最新版本兼容性问题的经验。 或者有什么新的方法可以将它们配置在一起,我错过了吗?
我正在处理同样的问题几个小时。 我注意到 :
[INFO] +- org.springframework.security:spring-security-core:jar:4.0.3.RELEASE:compile [INFO] | +- aopalliance:aopalliance:jar:1.0:compile [INFO] | \- org.springframework:spring-aop:jar:4.2.2.RELEASE:compile
这表明最新的spring-security-core版本4.0.3.RELEASE依赖于Spring Framework 4.2.2.RELEASE。
你有两个解决方案:
1)为spring-security-core排除spring-aop 4.2.2并明确地将spring-aop:jar:4.2.3.RELEASE的依赖描述添加到你的pom文件中。
2)将4.2.3.RELEASE依赖项更改为4.2.2.RELEASE并将Hibernate版本5.0.4.Final更改为5.0.2.Final
我选择第二种方式,它对我有用。
看一下spring-orm-4.2.3.RELEASE
的pom.xml
,它正在使用的hibernate的版本是5.0.3.Final
org.hibernate hibernate-core 5.0.3.Final compile true
它是一个可选的依赖项,因此不会将其解析为传递依赖项。 您仍然需要提供必要的hibernatejar,就像您目前正在做的那样。 您只需要将版本修改为它正在使用的正式版本。
5.0.3.Final
- 默认情况下,在Hibernate中为所有FetchType.LAZY非集合启用无代理行为
- Spring + Hibernate + JPA
- 无法打开JPA EntityManager进行交易; 嵌套exception是java.lang.IllegalStateException
- JPA:如何映射SQL Server uniqueidentifier类型
- Hibernate – 插入大blob的内存不足
- 强制hibernate在不改变映射的情况下急切地加载多个关联
- 处理Hibernate事务
- 获取org.hibernate.MappingException:没有JDBC类型的Dialect映射:-4exception?
- 正确使用Entity和DTO以在Restful Web服务中提供Json