作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我运行 spring boot 应用程序时,intellij 返回一个错误:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.hibernate.envers.boot.internal.TypeContributorImpl.contribute(TypeContributorImpl.java:30)
org.hibernate.boot.model.TypeContributions.contributeJavaTypeDescriptor(Lorg/hibernate/type/descriptor/java/spi/JavaTypeDescriptor;)V
jar:file:/C:/Users/romul/.m2/repository/org/hibernate/hibernate-core/5.4.6.Final/hibernate-core-5.4.6.Final.jar!/org/hibernate/boot/model/TypeContributions.class
jar:file:/C:/Users/romul/.m2/repository/org/hibernate/orm/hibernate-core/6.0.0.Alpha2/hibernate-core-6.0.0.Alpha2.jar!/org/hibernate/boot/model/TypeContributions.class
file:/C:/Users/romul/.m2/repository/org/hibernate/hibernate-core/5.4.6.Final/hibernate-core-5.4.6.Final.jar
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.produtos</groupId>
<artifactId>api-rest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>api-rest</name>
<description>Demo project for Spring Boot</description>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>12</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.8</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.26.0-GA</version>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.0.0.Alpha2</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.4.8.Final</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.4.0-b180830.0359</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
最佳答案
您不应将 Hibernate 的版本指定为 spring-boot-starter-data-jpa
依赖负责解决这个问题。
如果您运行 mvn dependency:tree | grep hibernate
,您会看到包含 2 个版本的 hibernate:
16:20 $ mvn dependency:tree | grep hibernate
[INFO] | | \- org.hibernate.validator:hibernate-validator:jar:6.0.17.Final:compile
[INFO] | +- org.hibernate:hibernate-core:jar:5.4.6.Final:compile
[INFO] +- org.hibernate.orm:hibernate-core:jar:6.0.0.Alpha2:compile
[INFO] | +- org.hibernate.common:hibernate-commons-annotations:jar:5.1.0.Final:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:5.4.8.Final:compile
org.hibernate
改变了至
org.hibernate.orm
,这就是 Maven 没有注意到它是同一个库的原因。
hibernate-entitymanager
可以删除依赖项。
关于maven - 启动 spring boot "An attempt was made to call a method that does not exist"时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58671257/
我是一名优秀的程序员,十分优秀!