gpt4 book ai didi

java - 错误注入(inject) : org. apache.maven.plugin.war.WarMojo

转载 作者:行者123 更新时间:2023-12-04 11:22:19 27 4
gpt4 key购买 nike

控制台打印的内容 ,我正在尝试在 netbeans 上运行一个 java web 应用程序,但我不太明白为什么它会给我这个错误。

Downloaded from central: https://repo.maven.apache.org/maven2/com/thoughtworks/xstream/xstream/1.4.4/xstream-1.4.4.jar (483 kB at 33 kB/s)
Error injecting: org.apache.maven.plugin.war.WarMojo
com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) Error injecting constructor, java.lang.ExceptionInInitializerError
at org.apache.maven.plugin.war.WarMojo.<init>(Unknown Source)
while locating org.apache.maven.plugin.war.WarMojo

1 error
at com.google.inject.internal.InternalProvisionException.toProvisionException (InternalProvisionException.java:226)
at com.google.inject.internal.InjectorImpl$1.get (InjectorImpl.java:1053)
at com.google.inject.internal.InjectorImpl.getInstance (InjectorImpl.java:1086)
at org.eclipse.sisu.space.AbstractDeferredClass.get (AbstractDeferredClass.java:48)
at com.google.inject.internal.ProviderInternalFactory.provision (ProviderInternalFactory.java:85)
无法在项目primera_web上执行目标org.apache.maven.plugins:maven-war-plugin:2.3:war (default-war): 执行目标org.apache.maven.plugins:maven-war-plugin的默认 war : 2.3:war failed: 由于 API 不兼容,无法在插件 'org.apache.maven.plugins:maven-war-plugin:2.3' 中加载 mojo 'war':org.codehaus.plexus.component.repository.exception .ComponentLookupException: 空
realm =    plugin>org.apache.maven.plugins:maven-war-plugin:2.3
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/Users/HP/.m2/repository/org/apache/maven/plugins/maven-war-plugin/2.3/maven-war-plugin-2.3.jar
urls[1] = file:/C:/Users/HP/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.0.6/maven-reporting-api-2.0.6.jar
urls[2] = file:/C:/Users/HP/.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/HP/.m2/repository/commons-cli/commons-cli/1.0/commons-cli-1.0.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 @5c82031b
-> [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>primera_web</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<name>primera_web</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>
解决问题的建议??

最佳答案

我有同样的问题。我正在使用 Eclipse 2021 年 6 月版。在 POM.xml 中手动配置最近的 war 插件之一后,问题得到解决。

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</plugin>

关于java - 错误注入(inject) : org. apache.maven.plugin.war.WarMojo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66920567/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com