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

时间:2022-09-14 00:01:36

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,当我在app root中使用mvn clean或mvn install时它工作正常但是当尝试在bash脚本中使用maven安装时我得到了以上异常:

this is my script:

这是我的脚本:

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

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安装工作,但建立从脚本不起作用,有什么想法吗?

2 个解决方案

#1


15  

Couple of possibilities...

几种可能性......

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

#2


7  

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

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

Try to:

尝试:

$ cd $M2_HOME

#1


15  

Couple of possibilities...

几种可能性......

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

#2


7  

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

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

Try to:

尝试:

$ cd $M2_HOME