Java Spring引导(Maven)中的不兼容依赖项
我已经开始使用Java Spring引导(Maven)中的不兼容依赖项,java,spring-boot,tomcat,intellij-idea,Java,Spring Boot,Tomcat,Intellij Idea,我已经开始使用springboot创建RESTful API。我已经两年没有碰过Spring了。我正在使用Maven。我的主要课程是: package com.tsakirogf.smartapi; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication publi
springboot
创建RESTful API。我已经两年没有碰过Spring了。我正在使用Maven
。我的主要课程是:
package com.tsakirogf.smartapi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SmartapiApplication
{
public static void main(String[] args)
{
SpringApplication.run(PeopleapiApplication.class, args);
}
}
我有一个控制器
,型号
和服务
。这是我的pom.xml
:
<?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 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.4.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.tsakirogf</groupId>
<artifactId>peopleapi</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>smartapi</name>
<description>Technical Test</description>
<properties>
<java.version>11</java.version>
<!-- <tomcat.version>8.5.63</tomcat.version>-->
</properties>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.200</version>
<!-- <scope>test</scope>-->
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.4.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>2.3.6.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
有什么想法或方向我应该移动?我已尝试同步依赖项,并尝试了
pom
中的最新版本和发行版软件包。我还删除了整个m2
repo(两次)。您的问题是F:/Workspace/Uni/softwareenger/peopleapi/lib/javax.servlet.jar。检查为什么在类路径中有这个JAR(很可能是通过一些脚本实现的)。这似乎比您在pom.xml中引用的版本旧您的问题是F:/Workspace/Uni/softwareenger/peopleapi/lib/javax.servlet.jar
。检查为什么在类路径中有这个JAR(很可能是通过一些脚本实现的)。这似乎比您在pom中引用的版本旧。xml@dunni这就解决了,邓尼。请你把它作为答案贴出来好吗?这一点是你应得的。非常感谢,我真的很感激。我想知道为什么mvn clean没有清除那个lib文件夹。这是我的假设。
2021-02-11 18:19:42.692 ERROR 14584 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
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.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1355)
The following method did not exist:
'java.lang.String javax.servlet.ServletContext.getVirtualServerName()'
The method's class, javax.servlet.ServletContext, is available from the following locations:
jar:file:/F:/Workspace/Uni/SoftwareEngineer/peopleapi/lib/javax.servlet.jar!/javax/servlet/ServletContext.class
jar:file:/C:/Users/Fotis/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.41/tomcat-embed-core-9.0.41.jar!/javax/servlet/ServletContext.class
The class hierarchy was loaded from the following locations:
javax.servlet.ServletContext: file:/F:/Workspace/Uni/SoftwareEngineer/peopleapi/lib/javax.servlet.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of javax.servlet.ServletContext
Process finished with exit code 1