简体   繁体   English

Mac OS X上预安装的Maven提供了java.lang.ClassNotFoundException

[英]Pre-installed Maven on Mac OS X gives java.lang.ClassNotFoundException

I tried to run pre-installed Maven with mvn command and get this error: 我尝试使用mvn命令运行预安装的Maven并获取此错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher

Running latest Mac OS X Mountain Lion and Java. 运行最新的Mac OS X Mountain Lion和Java。

That looks very familiar. 这看起来很熟悉。 I have seen that when M2_HOME was set to a Maven2 installation. 我已经看到当M2_HOME设置为Maven2安装时。

Do you have M2_HOME, or MAVEN_HOME set? 你有M2_HOME或MAVEN_HOME吗? This could be the culprit. 这可能是罪魁祸首。

There are some pretty major bugs in maven 3.0.3. maven 3.0.3中有一些非常重要的错误。 There are also really nice performance gains in 3.0.4 related to the maven http wagon, including connection pooling. 与maven http旅行车相关的3.0.4也有很好的性能提升,包括连接池。 If you find that your builds are running slower, do a mvn --version. 如果您发现构建运行速度较慢,请执行mvn --version。 The version that ships with Lion is 3.0.3. Lion附带的版本是3.0.3。

To fix this, do the following: 要解决此问题,请执行以下操作:

brew install maven sudo unlink /usr/share/maven cd /usr/share/ sudo ln -s /usr/local/Cellar/maven/3.0.4 maven brew install maven sudo unlink / usr / share / maven cd / usr / share / sudo ln -s /usr/local/Cellar/maven/3.0.4 maven

Making sure that the M2_HOME and MAVEN_HOME variables aren't set is pretty key to issues like this (for some reason Mac OS X doesn't need them and it causes issues). 确保未设置M2_HOME和MAVEN_HOME变量是这类问题的关键(出于某种原因,Mac OS X不需要它们并且它会导致问题)。 That's the usual culprit. 这是通常的罪魁祸首。 I would encourage you to upgrade to 3.0.4 as well though for the httpclient improvements if nothing else. 我鼓励你升级到3.0.4,但是对于httpclient改进,如果没有别的。

Please check which version of Maven & Java you are using. 请检查您正在使用的Maven和Java版本。

Your use case looks similar to the following blog post found online. 您的用例类似于在线发现的以下博客文章。

http://cyntech.wordpress.com/2011/03/09/maven-2-error/ http://cyntech.wordpress.com/2011/03/09/maven-2-error/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM