• maven编译开源项目报enforce错解决


    刚下载一个开源项目源码,用maven编译发现报错:

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce (enforce-versions) on project spark-parent_2.11: Some Enforcer rules
     have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

    根据报错提示信息得出是enforce插件检测规则失败,并且这里提供了一个官方解决连接,进入看看MojoExecutionException解释:

    说明这个不是maven本身报错,而是它的插件报错了,并且告诉我们要去看一下插件的文档,提供了maven插件文档的链接,进入plugin index找到enforce插件,先看看这个插件是干什么的:

    这里的对enforcer的解释是,这是做环境约束检查用,到pom.xml中找到对应的enforce插件:

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-enforcer-plugin</artifactId>
      <version>1.4.1</version>
      <executions>
        <execution>
          <id>enforce-versions</id>
          <goals>
            <goal>enforce</goal>
          </goals>
          <configuration>
            <rules>
              <requireMavenVersion>
                <version>${maven.version}</version>
              </requireMavenVersion>
              <requireJavaVersion>
                <version>${java.version}</version>
              </requireJavaVersion>
              <bannedDependencies>
                <excludes>
                  <!--
                    Akka depends on io.netty:netty, which puts classes under the org.jboss.netty
                    package. This conflicts with the classes in org.jboss.netty:netty
                    artifact, so we have to ban that artifact here. In Netty 4.x, the classes
                    are under the io.netty package, so it's fine for us to depend on both
                    io.netty:netty and io.netty:netty-all.
                  -->
                  <exclude>org.jboss.netty</exclude>
                  <exclude>org.codehaus.groovy</exclude>
                </excludes>
                <searchTransitive>true</searchTransitive>
              </bannedDependencies>
            </rules>
          </configuration>
        </execution>
      </executions>
    </plugin>

    这里对java.version和maven.version做了约束,把配置改成本地对应的版本号即可。

    参考:

    https://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

    http://maven.apache.org/plugins/

  • 相关阅读:
    解决myeclipse2014 中使用低版本的maven插件
    菜鸟成长之路-------使用过滤器实现自动登录
    动态代理
    JSON资料整理
    转账案例中引入事务
    ThreadLocal来管理事务
    【临窗旋墨-leetcode】0001-两数之和-[简单]
    shiro是如何清除过期session的(源码版本shiro1.6)
    [临窗旋墨]javaMelody初始化以及销毁时的处理逻辑及监控日志丢失问题排查
    Eclipse 的 git 插件操作 "代码提交"以及"代码冲突"
  • 原文地址:https://www.cnblogs.com/felixzh/p/10418252.html
Copyright © 2020-2023  润新知