Linux java.lang.NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher 运行 bash 文件以构建项目时

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6198677/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 04:19:47  来源:igfitidea点击:

java.lang.NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher when running bash file to build the project

linuxmaven-2mavenmaven-3

提问by Mahmoud Saleh

hi guys i have maven 2 installed, when i use mvn clean or mvn install in the app root it works fine but when trying to use maven install inside a bash script i got the above exception:

大家好,我已经安装了 maven 2,当我在应用程序根目录中使用 mvn clean 或 mvn install 时它工作正常,但是当尝试在 bash 脚本中使用 maven install 时,我得到了上述异常:

this is my script:

这是我的脚本:

#!/bin/sh
#dirname='/home/myuser/workspace/myapp'
DIRECTORY=$(cd `dirname 
$ cd $M2_HOME
` && pwd) cd $DIRECTORY mvn install -s resources/settings.xml

it was working fine with maven 3, but after i installed maven 2 and configured it, it stopped working and gave me above exception, i don't know what is the problem, since the regular build, mvn install works, but building from the script doesn't work, any ideas ?

它在 maven 3 上工作正常,但是在我安装了 maven 2 并对其进行了配置后,它停止工作并给了我上述异常,我不知道是什么问题,因为常规构建,mvn install 工作,但是从构建脚本不起作用,有什么想法吗?

采纳答案by Raghuram

Couple of possibilities...

几种可能性...

  • One, as posted here, you have both M2_REPO and M3_REPO variables defined.
  • Or you are facing thisissue related to maven3 and M2_HOME
  • The other is that somehow the JRE is getting used instead of JDK when run from the batch file!
  • 一,正如此处发布的,您定义了 M2_REPO 和 M3_REPO 变量。
  • 或者你正面临这个与 maven3 和 M2_HOME 相关的问题
  • 另一个是从批处理文件运行时,不知何故使用了 JRE 而不是 JDK!

回答by sourcerebels

I had this issue when my M2_HOME environment variable points to an incorrect location.

当我的 M2_HOME 环境变量指向不正确的位置时,我遇到了这个问题。

Try to:

尝试:

##代码##