gpt4 book ai didi

java - Maven,无法在我的 pom 中从 Hibernate 4 转到 Hibernate 5

转载 作者:行者123 更新时间:2023-11-30 07:50:13 24 4
gpt4 key购买 nike

在我的 Spring Boot 1.2.5 项目中,我不知道如何从 Hibernate 4 转到 Hibernate 5。目前,我的 pom 中有以下内容:

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.3.Final</version>
</dependency>

效果很好。如果我用这个替换它:

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.0.2.Final</version>
</dependency>

没那么多。它抛出一堆异常,如下所示:

Caused by: java.lang.ClassNotFoundException:     org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$Work
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:49)

我尝试将 JBoss 存储库添加到我的 pom 中,但这没有什么区别:

<repositories>

<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>

</repositories>

有什么技巧吗?

更新:

根据要求的依赖树:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building UA_Decision 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.9:tree (default-cli) @ decision ---
[INFO] edu.mit.ua:decision:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework:spring-core:jar:4.2.2.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-thymeleaf:jar:1.2.5.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:1.2.5.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot:jar:1.2.5.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.2.5.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:1.2.5.RELEASE:compile
[INFO] | | | +- org.slf4j:jul-to-slf4j:jar:1.7.12:compile
[INFO] | | | +- org.slf4j:log4j-over-slf4j:jar:1.7.12:compile
[INFO] | | | \- ch.qos.logback:logback-classic:jar:1.1.3:compile
[INFO] | | | \- ch.qos.logback:logback-core:jar:1.1.3:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.14:compile
[INFO] | +- org.thymeleaf:thymeleaf-spring4:jar:2.1.4.RELEASE:compile
[INFO] | | +- org.thymeleaf:thymeleaf:jar:2.1.4.RELEASE:compile
[INFO] | | | +- ognl:ognl:jar:3.0.8:compile
[INFO] | | | \- org.unbescape:unbescape:jar:1.1.0.RELEASE:compile
[INFO] | | \- org.slf4j:slf4j-api:jar:1.7.12:compile
[INFO] | \- nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:jar:1.2.9:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.2.5.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.2.5.RELEASE:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.0.23:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.0.23:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-logging-juli:jar:8.0.23:compile
[INFO] | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.0.23:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.4.6:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.4.6:compile
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.4.6:compile
[INFO] | +- org.hibernate:hibernate-validator:jar:5.1.3.Final:compile
[INFO] | | +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] | | \- com.fasterxml:classmate:jar:1.0.0:compile
[INFO] | +- org.springframework:spring-web:jar:4.1.7.RELEASE:compile
[INFO] | | \- org.springframework:spring-context:jar:4.1.7.RELEASE:compile
[INFO] | \- org.springframework:spring-webmvc:jar:4.1.7.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:4.1.7.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.2.5.RELEASE:test
[INFO] | +- junit:junit:jar:4.12:test
[INFO] | +- org.mockito:mockito-core:jar:1.10.19:test
[INFO] | | \- org.objenesis:objenesis:jar:2.1:test
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] | \- org.springframework:spring-test:jar:4.1.7.RELEASE:test
[INFO] +- org.hibernate:hibernate-entitymanager:jar:4.3.10.Final:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.1.3.GA:compile
[INFO] | +- org.jboss.logging:jboss-logging-annotations:jar:1.2.0.Beta1:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] | +- org.hibernate.common:hibernate-commons-annotations:jar:4.0.5.Final:compile
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.0.0.Final:compile
[INFO] | \- org.javassist:javassist:jar:3.18.1-GA:compile
[INFO] +- org.hibernate:hibernate-core:jar:5.0.2.Final:compile
[INFO] | +- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile
[INFO] | +- antlr:antlr:jar:2.7.7:compile
[INFO] | \- org.jboss:jandex:jar:1.2.2.Final:compile
[INFO] +- org.hibernate:hibernate-c3p0:jar:5.0.2.Final:compile
[INFO] | \- com.mchange:c3p0:jar:0.9.2.1:compile
[INFO] | \- com.mchange:mchange-commons-java:jar:0.2.3.4:compile
[INFO] +- com.oracle:ojdbc7:jar:12.1.0.1:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.2.5.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-aop:jar:1.2.5.RELEASE:compile
[INFO] | | +- org.aspectj:aspectjrt:jar:1.8.6:compile
[INFO] | | \- org.aspectj:aspectjweaver:jar:1.8.6:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.2.5.RELEASE:compile
[INFO] | | +- org.springframework:spring-jdbc:jar:4.1.7.RELEASE:compile
[INFO] | | \- org.apache.tomcat:tomcat-jdbc:jar:8.0.23:compile
[INFO] | | \- org.apache.tomcat:tomcat-juli:jar:8.0.23:compile
[INFO] | +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] | +- org.springframework:spring-orm:jar:4.1.7.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-jpa:jar:1.7.3.RELEASE:compile
[INFO] | | +- org.springframework.data:spring-data-commons:jar:1.9.3.RELEASE:compile
[INFO] | | \- org.slf4j:jcl-over-slf4j:jar:1.7.12:compile
[INFO] | \- org.springframework:spring-aspects:jar:4.1.7.RELEASE:compile
[INFO] +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.7:compile
[INFO] | \- org.codehaus.jackson:jackson-core-asl:jar:1.9.7:compile
[INFO] +- org.springframework.boot:spring-boot-configuration-processor:jar:1.2.5.RELEASE:compile
[INFO] | \- org.json:json:jar:20140107:compile
[INFO] +- org.springframework.boot:spring-boot-starter-amqp:jar:1.2.5.RELEASE:compile
[INFO] | +- org.springframework:spring-messaging:jar:4.1.7.RELEASE:compile
[INFO] | +- org.springframework:spring-tx:jar:4.1.7.RELEASE:compile
[INFO] | \- org.springframework.amqp:spring-rabbit:jar:1.4.5.RELEASE:compile
[INFO] | +- com.rabbitmq:amqp-client:jar:3.5.5:compile
[INFO] | +- org.springframework.retry:spring-retry:jar:1.1.2.RELEASE:compile
[INFO] | \- org.springframework.amqp:spring-amqp:jar:1.4.5.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:1.2.5.RELEASE:compile
[INFO] | \- org.springframework.boot:spring-boot-actuator:jar:1.2.5.RELEASE:compile
[INFO] +- org.springframework.ws:spring-ws-core:jar:2.2.1.RELEASE:compile
[INFO] | +- org.springframework.ws:spring-xml:jar:2.2.1.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:4.1.7.RELEASE:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework:spring-beans:jar:4.1.7.RELEASE:compile
[INFO] | \- org.springframework:spring-oxm:jar:4.1.7.RELEASE:compile
[INFO] +- com.oracle:ucp:jar:12.1.0.2:compile
[INFO] \- com.oracle:ons:jar:12.1.0.2:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.571 s
[INFO] Finished at: 2015-10-28T18:10:50-04:00
[INFO] Final Memory: 20M/437M
[INFO] ------------------------------------------------------------------------

最佳答案

如果您想覆盖 Spring Boot 管理的版本,则应该仅使用 Spring Boot 提供的属性。您可以在 pom.xml 中检查项目 spring-boot-dependencies ( https://github.com/spring-projects/spring-boot/blob/master/spring-boot-dependencies/pom.xml ) 的可用属性。

根据您的情况,您应该定义以下属性:

<hibernate.version>5.0.3.Final</hibernate.version>
<spring.version>4.2.2.RELEASE</spring.version>

这将确保该框架所需的所有库都使用相同的版本。

关于java - Maven,无法在我的 pom 中从 Hibernate 4 转到 Hibernate 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33400786/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com