簡體   English   中英

如何在 Eclipse 中刪除 maven 依賴 jar

[英]How can I remove maven dependency jar in Eclipse

我對 Maven 真的很陌生,只是將我的應用引擎項目轉換為 Maven 項目。 我在pom.xml文件中添加了依賴項以消除錯誤。 但現在我進入了我的代碼

方法 getPart(String) 未定義為 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 dependencies中得到的圖像。

我的猜測是錯誤來自 2.5 版本的 servlet-api。

構建路徑部分 與 servlet-api 2.5 和 3.1 的最終沖突

所以非常感謝任何幫助,我看到了一些關於exclusion標簽的信息,但我什至不知道把它放在哪里,因為它看起來不像pom.xml任何東西要求這個 jar。

您最好在 Eclipse 中打開您的 pom.xml 文件並切換到“依賴層次結構”選項卡。 查找不需要的庫(在過濾器中輸入“serlvet”)並通過上下文菜單添加排除項。 這將修改您的 pom.xml 文件。

從工作區刪除項目,不要選中刪除磁盤上的項目內容。 也從 .m2 文件夾中刪除 jar。 使用 eclipse 導入項目。 打開 pom 文件並單擊依賴層次結構。 選擇要刪除的 jar。 右鍵單擊並單擊排除 Maven 工件。 下次運行 proejct 時,它不會下載 jar。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM