簡體   English   中英

無法使用 maven 項目構建依賴項

[英]Unable to build with dependencies with a maven project

大家好,希望你們過得很好。

所以我是 Maven 的新手。我創建了一個 maven 項目@Apache NetBeans IDE 13、java JDK 17.02 和 Apache 18584537.8 服務器每次我嘗試使用依賴項進行構建時,我都會收到此特定錯誤,“無法執行目標 org.apache.maven.plugins:maven-war-plugin:2.3:war (default-war) on project ECommerceWebsite: Execution default-war目標 org.apache.maven.plugins:maven-war-plugin:2.3:war 失敗:由於 88100308512 incompatibility,無法在插件 'org.apache.maven.plugins:maven-war-plugin:2.3' 中加載 mojo 'war' :org.codehaus.plexus.component.repository.exception.ComponentLookupException:null “。 我花了幾個小時試圖修復這個錯誤。 試圖解決一些以前問過這個問題的用戶。

  • 我刪除了 .m2 文件夾,但重建后仍然出現相同的錯誤。 所以我需要建議如何解決這個錯誤。 這是我收到的錯誤。
Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.3:war (default-war) on project ECommerceWebsite: Execution default-war of goal org.apache.maven.plugins:maven-war-plugin:2.3:war failed: Unable to load the mojo 'war' in the plugin 'org.apache.maven.plugins:maven-war-plugin:2.3' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: null
-----------------------------------------------------
realm =    plugin>org.apache.maven.plugins:maven-war-plugin:2.3
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/Users/Mritunjay/.m2/repository/org/apache/maven/plugins/maven-war-plugin/2.3/maven-war-plugin-2.3.jar
urls[1] = file:/C:/Users/Mritunjay/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.0.6/maven-reporting-api-2.0.6.jar
urls[2] = file:/C:/Users/Mritunjay/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.0-alpha-7/doxia-sink-api-1.0-alpha-7.jar
urls[3] = file:/C:/Users/Mritunjay/.m2/repository/commons-cli/commons-cli/1.0/commons-cli-1.0.jar
urls[4] = file:/C:/Users/Mritunjay/.m2/repository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar
urls[5] = file:/C:/Users/Mritunjay/.m2/repository/org/apache/maven/maven-archiver/2.5/maven-archiver-2.5.jar
urls[6] = file:/C:/Users/Mritunjay/.m2/repository/org/codehaus/plexus/plexus-io/2.0.5/plexus-io-2.0.5.jar
urls[7] = file:/C:/Users/Mritunjay/.m2/repository/org/codehaus/plexus/plexus-archiver/2.2/plexus-archiver-2.2.jar
urls[8] = file:/C:/Users/Mritunjay/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.15/plexus-interpolation-1.15.jar
urls[9] = file:/C:/Users/Mritunjay/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar
urls[10] = file:/C:/Users/Mritunjay/.m2/repository/com/thoughtworks/xstream/xstream/1.4.3/xstream-1.4.3.jar
urls[11] = file:/C:/Users/Mritunjay/.m2/repository/xmlpull/xmlpull/1.1.3.1/xmlpull-1.1.3.1.jar
urls[12] = file:/C:/Users/Mritunjay/.m2/repository/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar
urls[13] = file:/C:/Users/Mritunjay/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.8/plexus-utils-3.0.8.jar
urls[14] = file:/C:/Users/Mritunjay/.m2/repository/org/apache/maven/shared/maven-filtering/1.0-beta-2/maven-filtering-1.0-beta-2.jar
Number of foreign imports: 1
import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

-----------------------------------------------------
: ExceptionInInitializerError: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module @4391a2d8
-> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException

這是 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.mycompany</groupId>
    <artifactId>ECommerceWebsite</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>ECommerceWebsite</name>

    <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax</groupId>
                                    <artifactId>javaee-endorsed-api</artifactId>
                                    <version>7.0</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

根據https://maven.apache.org/plugins/更新插件,它非常適合我。

暫無
暫無

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

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