zoukankan      html  css  js  c++  java
  • Maven报错Please ensure you are using JDK 1.4 or above and not a JRE

    在部署Jenkins项目时,用Jenkins调用服务器上脚本时,脚本在服务器上执行没有任何问题,但是在Jenkins上调用时就报错,提示mvn应该使用全路径执行,当加入jdk,jre,maven环境变量时,出现下面错误。

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project kpl-model: Compilation failure
    [ERROR] Unable to locate the Javac Compiler in:
    [ERROR]   /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el6_9.x86_64/jre/../lib/tools.jar
    [ERROR] Please ensure you are using JDK 1.4 or above and
    [ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
    [ERROR] In most cases you can change the location of your Java
    [ERROR] installation by setting the JAVA_HOME environment variable.
    [ERROR] 

    而maven编译需要jdk作为运行环境。
    因此,我们只要设置为jdk即可,去掉jre环境变量即可。

    #!/bin/bash
    export JAVA_HOME=/usr/local/jdk
    export M2_HOME=/opt/apache-maven
    export PATH=$JAVA_HOME/bin:$PATH
    export PATH=${M2_HOME}/bin:${PATH}
    export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

    注:使用which java,mvn -v可查询环境变量的家目录

  • 相关阅读:
    ASP.NET伪静态配置
    拖动条控件 (UISlider)
    进度环控件 (UIActivityIndicatorView)
    进度条控件 (UIProgressView)
    图像控件 (UIImageView)
    分段控件 (UISegmentedControl)
    CocoaPods安装和使用教程
    iOS 在UILabel显示不同的字体和颜色
    iOS开源项目(新)
    iOS开源项目(旧)
  • 原文地址:https://www.cnblogs.com/dadonggg/p/11122873.html
Copyright © 2011-2022 走看看