我正在尝试通过本教程制作Bukkit插件:
http://wiki.bukkit.org/Plugin_Tutorial
一切都很好,除了当我尝试以任何方式(清洁,构建,测试)使用Maven构建项目时,它都会给我以下错误:
java.lang.NoClassDefFoundError: org/eclipse/osgi/internal/baseadaptor/DevClassPathHelper
at org.eclipse.m2e.core.internal.embedder.MavenEmbeddedRuntime.addBundleClasspathEntries(MavenEmbeddedRuntime.java:193)
at org.eclipse.m2e.core.internal.embedder.MavenEmbeddedRuntime.initClasspath(MavenEmbeddedRuntime.java:127)
at org.eclipse.m2e.core.internal.embedder.MavenEmbeddedRuntime.createLauncherConfiguration(MavenEmbeddedRuntime.java:107)
at org.eclipse.m2e.internal.launch.MavenRuntimeLaunchSupport.create(MavenRuntimeLaunchSupport.java:119)
at org.eclipse.m2e.internal.launch.MavenLaunchDelegate.launch(MavenLaunchDelegate.java:70)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:883)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:739)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1039)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1256)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.ClassNotFoundException: org.eclipse.osgi.internal.baseadaptor.DevClassPathHelper cannot be found by org.eclipse.m2e.core_1.4.0.20130601-0317
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:423)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:336)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:328)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 10 more
我的pom.xml如下:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.learning25</groupId>
<artifactId>TestPlugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.6.4-R2.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
最佳答案
我自己也遇到了同样的问题。它似乎是由此错误引起的,并且是Eclipse Luna和M2E插件引起的问题:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=412436
假设您正在使用Luna并安装了M2E,我通过卸载M2E并使用“安装新软件”途径而非“市场”途径进行重新安装来解决了该问题。无法说出原因,但这似乎对我有用。