maven错误无法访问属性的defaults字段

anauzrmj  于 2021-07-14  发布在  Java
关注(0)|答案(0)|浏览(256)

我使用最新版本的java->16。当我运行mvn clean时,我发现无法初始化类org.apache.maven.plugin.war.util.webappstructuresializer错误。我读到添加maven-war插件可以是一个解决方案,但对我不起作用。运行mvn install时,出现以下错误:
注入构造函数时出错,java.lang.exceptionininitializererror:在定位org.apache.maven.plugin.war.warmojo时,无法访问org.apache.maven.plugin.war.warmojo中属性的defaults字段(未知源)
如何解决这些问题?它们是由java版本引起的吗?

<modelVersion>4.0.0</modelVersion>

<groupId>web-programming</groupId>
<artifactId>servlet-demo</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>

<properties>
    <java.version>16</java.version>
    <maven.compiler.target>${java.version}</maven.compiler.target>
    <maven.compiler.source>${java.version}</maven.compiler.source>
</properties>

<dependencies>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.1.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <!-- Optional. Allows the app to be run by simply typing mvn jetty:run -->
        <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <version>6.1.4</version>
            <dependencies>
                <dependency>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                    <version>1.2.13</version>
                </dependency>
            </dependencies>
            <configuration>
                <contextPath>/</contextPath>
                <scanIntervalSeconds>10</scanIntervalSeconds>
                <connectors>
                    <connector
                        implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                        <port>9090</port>
                    </connector>
                </connectors>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.2</version>
        </plugin>
    </plugins>
</build>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题