执行命令mvn时报错
错误:找不到或无法加载主类 org.codehaus.classworlds.Launcher
解决方法:很可能为系统安装过其他版本的maven,用which mvn
定位脚本检查
hadoop@Master:/usr/bin$ which mvn
/usr/local/apache-maven-3.5.2/bin/mvn
hadoop@Master:/usr/bin$
若发现与自己配置的M2_HOME
路径不一致,则确认为系统在启动maven时,调用的是旧版本的bin/mvn脚本。删除该脚本并重新加载配置文件,比如旧版本路径为usr/bin/mvn
sudo rm -rf /usr/bin/mvn
source ~/.bashrc
删除后若忘记重新加载配置文件~/.bashrc
,则会报错
错误: 找不到或无法加载主类 org.codehaus.plexus.classworlds.launcher.Launcher
再执行mvn -version
命令,若显示如下成功则配置完成
hadoop@Master:/usr/bin$ mvn -version
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T15:58:13+08:00)
Maven home: /usr/local/apache-maven-3.5.2
Java version: 1.8.0_151, vendor: Oracle Corporation
Java home: /home/hadoop/MyLocal/jdk1.8.0_151/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "4.2.0-27-generic", arch: "amd64", family: "unix"