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/

转载于:https://www.cnblogs.com/felixzh/p/10418252.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Maven是一个优秀的构建工具,可以用于构建各种类型的项目,包括nodejs项目。下面是使用Maven编译nodejs项目的步骤: 1. 配置Maven环境 首先,需要在本地安装Maven,并配置好环境变量。安装完成后,在命令行中输入`mvn -v`,如果能输出Maven的版本信息,则说明Maven环境配置成功。 2. 创建nodejs项目 在本地创建一个nodejs项目,并编写好相应的代码。 3. 创建Maven项目 在nodejs项目的根目录下,创建一个名为pom.xml的文件,该文件是Maven项目的配置文件。 4. 配置Maven插件 在pom.xml文件中,添加以下代码,配置Maven插件: ``` <build> <plugins> <plugin> <groupId>com.github.eirslett</groupId> <artifactId>frontend-maven-plugin</artifactId> <version>1.10.0</version> <executions> <execution> <id>install node and npm</id> <goals> <goal>install-node-and-npm</goal> </goals> <configuration> <nodeVersion>v12.18.3</nodeVersion> <npmVersion>6.14.6</npmVersion> </configuration> </execution> <execution> <id>npm install</id> <goals> <goal>npm</goal> </goals> <configuration> <arguments>install</arguments> </configuration> </execution> <execution> <id>npm run build</id> <goals> <goal>npm</goal> </goals> <configuration> <arguments>run build</arguments> </configuration> </execution> </executions> </plugin> </plugins> </build> ``` 该插件使用了frontend-maven-plugin插件,可以自动下载和安装node和npm,并执行npm命令来进行项目构建。 5. 执行Maven命令 在命令行中输入以下命令,执行Maven构建命令: ``` mvn clean install ``` 该命令会自动执行pom.xml文件中配置的插件,并进行项目构建。 以上就是使用Maven编译nodejs项目的步骤,希望能对你有所帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值