运行Maven时出错

时间:2014-01-31 05:05:00

标签: maven

我正在尝试构建一个maven(最新版本3.1.1)项目,并且出于某种原因,当我运行任何maven命令时,例如maven clean或maven compile,我收到以下错误:

Exception in thread "main" java.lang.IllegalAccessError: tried to access method org.slf4j.LoggerFactory.reset()V from class org.slf4j.MavenSlf4jFriend
at org.slf4j.MavenSlf4jFriend.reset(MavenSlf4jFriend.java:33)
at org.apache.maven.cli.logging.impl.Slf4jSimpleConfiguration.activate(Slf4jSimpleConfiguration.java:60)
at org.apache.maven.cli.MavenCli.logging(MavenCli.java:348)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:205)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

2 个答案:

答案 0 :(得分:2)

使用Brew安装的OS X 10.9上的Maven存在同样的问题。事实证明,Maven将自己的库包括slf4j带入/usr/local/Cellar/maven/3.2.2/libexec/lib。但是,我在slf4j

的类路径中已经有了/Library/Java/Extensions的另一个版本

解决方案:从OS X默认类路径中删除slf4j,以便Maven可以使用其版本而不会发生冲突。

答案 1 :(得分:1)

尝试更改Java JDK版本并重新安装maven。它对我有用。即使我遇到了同样的错误,但也找不到合适的解决方案。我已经将我的JDK版本1.8更改为JDK 9.0.1并重新安装了Maven,它运行良好。