我在运行Springboot Maven应用程序时遇到问题。这个问题始于一个缺失的依赖关系,这让我无法解决另一个问题,我尝试了来自整个网络的多个建议,但都无济于事。我确实移除了。m2文件夹并重新构建,但同样的错误再次出现。
我控制台中的错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.<init>(PersistenceAnnotationBeanPostProcessor.java:650)
The following method did not exist:
'javax.persistence.SynchronizationType javax.persistence.PersistenceContext.synchronization()'
The calling method's class, org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement, was loaded from the following location:
jar:file:/C:/Users/Kevin/.m2/repository/org/springframework/spring-orm/5.3.19/spring-orm-5.3.19.jar!/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor$PersistenceElement.class
The called method's class, javax.persistence.PersistenceContext, is available from the following locations:
jar:file:/D:/School%20Novi/Eindopdracht/BackEnd/demodrop-be/lib/javax.persistence.jar!/javax/persistence/PersistenceContext.class
jar:file:/C:/Users/Kevin/.m2/repository/jakarta/persistence/jakarta.persistence-api/2.2.3/jakarta.persistence-api-2.2.3.jar!/javax/persistence/PersistenceContext.class
jar:file:/C:/Users/Kevin/.m2/repository/javax/persistence/javax.persistence-api/2.2/javax.persistence-api-2.2.jar!/javax/persistence/PersistenceContext.class
The called method's class hierarchy was loaded from the following locations:
javax.persistence.PersistenceContext: file:/D:/School%20Novi/Eindopdracht/BackEnd/demodrop-be/lib/javax.persistence.jar
Action:
Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement and javax.persistence.PersistenceContext
Process finished with exit code 1
我的pom。xml:
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.7</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demodrop-be</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demodrop-be</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.28</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.6.7</version>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
欢迎任何意见。
谢谢大家,删除提到的依赖项解决了这个问题。这一切都始于一个错误,说明javax.persistence未加载,这是由依赖项的不当选择事后造成的。我大约5个月前才开始学习前端和后端开发的在线课程,所以它仍然有点令人生畏。
在一个RCE漏洞之后,我最近通过sprint boot升级到了2.6.6。然而,现在我的应用程序并没有开始与错误: 应用程序无法启动 描述: __________: 试图调用不存在的方法。尝试从以下位置进行:org.springframework.boot.SpringApplication.run(SpringApplication.java:301) 以下方法不存在:org.springfra
我有个问题。尝试改变版本(就像它在互联网上说的),但没有帮助。我已经读过了,这些答案修正了应用程序的类路径,使它包含一个单一的、兼容的org.springframework.plugin.core.pluginregistry版本,但它也没有帮助。 问题: 更正应用程序的类路径,使其包含Org.SpringFramework.http.Converter.Support.AllEncompassi
我正在使用spring cloud将一个模块化应用程序迁移到一个microsevrices应用程序中,当我将一个模块迁移到microservice并运行它时,出现了一个问题: 更正应用程序的类路径,使其包含org.springframework.plugin.core.pluginregistry的一个兼容版本 这是一个错误: 这是我的pom.xml: 这是我的swaggreconfig.java
我正在尝试通过hibernate和Spring-Boot连接MongoDB数据库。当我试图连接到MongoDB时,我得到了以下错误。请帮我通过Hibernate连接。在我的build.gradle中,我只有“hibernate-ogm-mongoDB”依赖项。
我在运行我的Spring boot应用程序时遇到以下错误,我是Spring boot和弹性搜索的新手,请帮助解决这个问题。并在下面附上了我的pom依赖项。提前感谢, ****************************应用程序启动失败***************************************************