java - 如何在 Eclipse 中删除 maven 依赖 jar
问题描述
我对 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>
这是我Maven dependencies
在构建路径中获得的图像。
我的猜测是错误来自 servlet-api 的 2.5 版本。
所以非常感谢任何帮助,我看到了一些关于exclusion
标签的东西,但甚至不知道把它放在哪里,因为它看起来不像pom.xml
是在要求这个罐子里的任何东西。
解决方案
您最好在 Eclipse 中打开您的 pom.xml 文件并切换到“依赖层次”选项卡。查找不需要的库(在过滤器中输入“serlvet”)并通过上下文菜单在其上添加排除项。这将修改您的 pom.xml 文件。
推荐阅读
- filenet-p8 - 如何在 FileNet P8 保存的搜索中为 ClassDescription 属性设置别名?
- node.js - 电子节点-Gyp 库未加载:dylib
- c++ - 泰语本地化中的音调标记在 C++/DirectX 渲染中呈现为单独的字符
- javascript - JavaScript 已链接,但不会显示在 Chrome 开发者控制台中
- python - Alexa Python Skill 获取口语值而不是插槽 id
- tensorflow - 在 tensorflow 中,是否可以看到其他模型构建结构?
- graph-theory - 计算诱导子图,对路径而不是边进行归纳
- python - 如何在 python 中用海龟写我的名字?
- javascript - 拒绝加载脚本“https://apis.google.com/js/platform.js”,因为它违反了以下内容安全政策
- python - 在 ini 文件中使用 JSON 路径