解决Maven打包项目为war报错:[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war

maven打包项目为war时出现以下报错:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project web-demo: Execution default-war of goal org.apache.maven.plugins:maven-war-plugin:2.2:war failed: Unable to load the mojo 'war' in the plugin 'org.apache.maven.plugins:maven-war-plugin:2.2' due to an API incompatibility:org.codehaus.plexus.component.repository.exception.ComponentLookupException: Cannot access defaults field of Properties 

翻译:

在项目web-demo上执行目标org.apache.maven.plugins:maven-war:2.2:war失败:无法加载插件org.apache.maven.plugins:maven-war:2.2中的mojo 'war',因为API不兼容:org.codehaus.plexus.component.repository. exception.com componentlookupexception:无法访问属性的默认字段

 从错误提示我们可以知道,这是因为插件版本与API不兼容导致的错误。

 解决方法:

在pom.xml文件的<project> </project>中添加如下插件:

   <build>
        <!-- To define the plugin version in your parent POM -->
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>3.3.1</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <!-- To use the plugin goals in your POM or parent POM -->
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.3.1</version>
            </plugin>
        </plugins>
    </build>

 

  • 11
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值