java - 如何在 Eclipse 中删除 Maven 依赖 jar

标签 java eclipse maven google-app-engine

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

The method getPart(String) is undefined for the type HttpServletRequest

因此,在对 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>

这是我在构建路径中的 Maven 依赖项 中获得的图像。

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

build path section eventual conflict with servlet-api 2.5 and 3.1

非常感谢任何帮助,我看到了一些关于exclusion的内容 标记,但甚至不知道将它放在哪里,因为它看起来不像 pom.xml 中的任何东西都在请求这个 jar。

最佳答案

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

关于java - 如何在 Eclipse 中删除 Maven 依赖 jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56209033/

相关文章:

java - java中的文件处理

java - 如何停止关于目标文件夹内容的 Eclipse 警告?

java - 以编程方式检查 .class 文件是否扩展特定类

java - 如何存储给定的响应(以 TextView 形式给出)并在给出响应时再次使用它们

java - 检查所有函数中的所有函数参数

java - JFreeChart 使 XYSeriescollection 可迭代

java - Maven 错误 : Could not find or load main class MLSH-0. 0.1-SNAPSHOT.Jar

java - 如何聚合maven子项目javadoc输出而不重新生成javadoc

maven - 禁用在 maven 中查找错误

maven - 给定组中所有包含的 Artifact 对相同版本的依赖