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可查询环境变量的家目录

  • 相关阅读:
    多个表单项的动态校验
    js遍历循坏二维数组,显示天气情况
    纯css3 实现的焦点图
    实现元素水平和垂直居中的问题
    简易商品购物车
    用jquery的animate动画做成的左侧菜单伸缩
    MongoDB聚合
    NoSQL介绍
    MongoDB索引
    数据库索引简介
  • 原文地址:https://www.cnblogs.com/dadonggg/p/11122873.html
Copyright © 2011-2022 走看看