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/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM