如何删除Eclipse中的maven依赖jar

JSm*_*ith 3 java eclipse google-app-engine maven

我对 Maven 非常陌生,刚刚将我的应用程序引擎项目转换为 Maven 项目。我在pom.xml文件中添加了依赖项以消除错误。但现在我进入了我的代码

HttpServletRequest 类型的方法 getPart(String) 未定义

因此,在对 Stack Overflow 进行了一些研究之后,我似乎需要一个单独的更新包servlet-api才能使其正常工作。

显然,我可能与我的 Maven 依赖项中的旧版本有冲突,但我从未将其添加到 中,pom.xml现在我被这个 jar 困住了,不知道为什么导入它以及如何删除它。

这是我的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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>my-project</groupId>
  <artifactId>my-project</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.2.1</version>
            <configuration>
                 <webResources>
                    <resource>
                        <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                        <filtering>true</filtering>
                        <targetPath>WEB-INF</targetPath>
                    </resource>
                </webResources>
            </configuration>
      </plugin>
      <plugin>
        <groupId>com.google.cloud.tools</groupId>
        <artifactId>appengine-maven-plugin</artifactId>
         <version>1.3.1</version>
            <configuration>
                 <deploy.promote>true</deploy.promote>
                <deploy.stopPreviousVersion>true</deploy.stopPreviousVersion>
            </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
    </dependency>
    <dependency>
        <groupId>com.mailjet</groupId>
        <artifactId>mailjet-client</artifactId>
        <version>4.2.1</version>
    </dependency>
    <dependency>
        <groupId>com.google.appengine.tools</groupId>
        <artifactId>appengine-gcs-client</artifactId>
        <version>0.8</version>
    </dependency>
  </dependencies>
  <properties>
  <maven.compiler.source>1.8</maven.compiler.source>
  <maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
Run Code Online (Sandbox Code Playgroud)

这是我Maven dependencies在构建路径中得到的图像。

我的猜测是该错误来自 servlet-api 的 2.5 版本。

构建路径部分 最终与 servlet-api 2.5 和 3.1 发生冲突

因此,非常感谢任何帮助,我看到了有关exclusion 标签的一些内容,但甚至不知道将其放在哪里,因为它看起来不像需要pom.xml这个罐子的任何内容。

Lit*_*nti 6

您最好在 Eclipse 中打开 pom.xml 文件并切换到“依赖关系层次结构”选项卡。查找不需要的库(在过滤器中输入“servet”)并通过上下文菜单添加排除项。这将修改您的 pom.xml 文件。