简体   繁体   English

由于 API 不兼容,Maven 战争插件 3.0.0 出现问题

[英]Problem with Maven war plugin 3.0.0 due to an API incompatibility

I'm following this JSF tutorial https://www.tutorialspoint.com/jsf/index.htm .我正在关注这个 JSF 教程https://www.tutorialspoint.com/jsf/index.htm I think I've done everything that was written there (downloading all the required sw, setting the environment with path to the variables, etc.) but I cannot resolve a compilation problem with Maven war plugin.我想我已经完成了那里编写的所有内容(下载所有必需的软件,使用变量路径设置环境等),但我无法解决 Maven 战争插件的编译问题。 I've already read a lot of questions and possible solutions and I think I've tried most of the combination proposed (mvn clean then install, set the correct version of jdk, point to jdk directory instead of jde, remove.m2 repository, forced upgrade of the project, etc.).我已经阅读了很多问题和可能的解决方案,我想我已经尝试了大多数建议的组合(mvn clean 然后安装,设置正确的 jdk 版本,指向 jdk 目录而不是 jde,remove.m2 存储库,项目的强制升级等)。 So, here I am, maybe describing my specific problem will help to understand how to solve it.所以,我在这里,也许描述我的具体问题将有助于理解如何解决它。

Output of mvn clean install: mvn 全新安装的 Output:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:3.0.0:war (default-war) on project helloworld: Execution default-war of goal org.apache.maven.plugins:maven-war-plugin:3.0.0:war failed: Unable to load the mojo 'war' in the plugin 'org.apache.maven.plugins:maven-war-plugin:3.0.0' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: null
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.apache.maven.plugins:maven-war-plugin:3.0.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/do.romano/.m2/repository/org/apache/maven/plugins/maven-war-plugin/3.0.0/maven-war-plugin-3.0.0.jar
[ERROR] urls[1] = file:/C:/Users/do.romano/.m2/repository/org/sonatype/sisu/sisu-inject-bean/1.4.2/sisu-inject-bean-1.4.2.jar
[ERROR] urls[2] = file:/C:/Users/do.romano/.m2/repository/org/sonatype/sisu/sisu-guice/2.1.7/sisu-guice-2.1.7-noaop.jar
[ERROR] urls[3] = file:/C:/Users/do.romano/.m2/repository/org/sonatype/aether/aether-util/1.7/aether-util-1.7.jar
[ERROR] urls[4] = file:/C:/Users/do.romano/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.6/plexus-component-annotations-1.6.jar
[ERROR] urls[5] = file:/C:/Users/do.romano/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[6] = file:/C:/Users/do.romano/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[7] = file:/C:/Users/do.romano/.m2/repository/org/apache/maven/maven-archiver/3.1.1/maven-archiver-3.1.1.jar
[ERROR] urls[8] = file:/C:/Users/do.romano/.m2/repository/org/apache/maven/shared/maven-shared-utils/3.0.1/maven-shared-utils-3.0.1.jar
[ERROR] urls[9] = file:/C:/Users/do.romano/.m2/repository/commons-io/commons-io/2.5/commons-io-2.5.jar
[ERROR] urls[10] = file:/C:/Users/do.romano/.m2/repository/org/codehaus/plexus/plexus-archiver/3.4/plexus-archiver-3.4.jar
[ERROR] urls[11] = file:/C:/Users/do.romano/.m2/repository/org/codehaus/plexus/plexus-io/2.7.1/plexus-io-2.7.1.jar
[ERROR] urls[12] = file:/C:/Users/do.romano/.m2/repository/org/apache/commons/commons-compress/1.11/commons-compress-1.11.jar
[ERROR] urls[13] = file:/C:/Users/do.romano/.m2/repository/org/iq80/snappy/snappy/0.4/snappy-0.4.jar
[ERROR] urls[14] = file:/C:/Users/do.romano/.m2/repository/org/tukaani/xz/1.5/xz-1.5.jar
[ERROR] urls[15] = file:/C:/Users/do.romano/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.22/plexus-interpolation-1.22.jar
[ERROR] urls[16] = file:/C:/Users/do.romano/.m2/repository/com/thoughtworks/xstream/xstream/1.4.9/xstream-1.4.9.jar
[ERROR] urls[17] = file:/C:/Users/do.romano/.m2/repository/xmlpull/xmlpull/1.1.3.1/xmlpull-1.1.3.1.jar
[ERROR] urls[18] = file:/C:/Users/do.romano/.m2/repository/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar
[ERROR] urls[19] = file:/C:/Users/do.romano/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.24/plexus-utils-3.0.24.jar
[ERROR] urls[20] = file:/C:/Users/do.romano/.m2/repository/org/apache/maven/shared/maven-filtering/3.1.1/maven-filtering-3.1.1.jar
[ERROR] urls[21] = file:/C:/Users/do.romano/.m2/repository/org/sonatype/plexus/plexus-build-api/0.0.7/plexus-build-api-0.0.7.jar
[ERROR] urls[22] = file:/C:/Users/do.romano/.m2/repository/org/apache/maven/shared/maven-mapping/3.0.0/maven-mapping-3.0.0.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] : 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 @6f798482
[ERROR] -> [Help 1]

Maven version: Maven版本:

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: C:\Program Files\apache-maven-3.8.1\bin\..
Java version: 16.0.1, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-16.0.1
Default locale: it_IT, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Java version: Java版本:

java version "16.0.1" 2021-04-20
Java(TM) SE Runtime Environment (build 16.0.1+9-24)
Java HotSpot(TM) 64-Bit Server VM (build 16.0.1+9-24, mixed mode, sharing)

Eclipse error which point the the first row of pom.xml: https://i.ibb.co/t4CNwR3/problema4.png Eclipse 错误指向第一行 pom.xml: https://i.ibb.co/t4CNwR3/proble

pom.xml: 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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.tutorialspoint.test</groupId>
  <artifactId>helloworld</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>helloworld Maven Webapp</name>
  <url>http://maven.apache.org</url>
  
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  
    <dependency>
      <groupId>com.sun.faces</groupId>
      <artifactId>jsf-api</artifactId>
      <version>2.1.7</version>
    </dependency>
    
    <dependency>
      <groupId>com.sun.faces</groupId>
      <artifactId>jsf-impl</artifactId>
      <version>2.1.7</version>
    </dependency>
  </dependencies>
  
  <build>
    <finalName>helloworld</finalName>
    <plugins>
    
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
               <source>16.0.1</source>
               <target>16.0.1</target>
               <compilerArgument>-Xlint:all</compilerArgument>
               <showWarnings>true</showWarnings>
               <showDeprecation>true</showDeprecation>
            </configuration>
         </plugin>
         
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.0.0</version>
            <configuration>
                <webResources>
                   <resource>
                      <directory>WebContent</directory>
                   </resource>
                </webResources>
                <useCache>false</useCache>
            </configuration>
         </plugin>

    </plugins>
  </build>
</project>

The versions of Maven and Java are very current, but the war plugin version is not. Maven 和 Java 的版本非常新,但是战争插件版本不是。 Try using the most current version, which per website is 3.3.1 (at the time of original answer).尝试使用最新版本,每个网站是 3.3.1(在原始答案时)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM