最近和业余的java开发者,在Eclipse IDE上,我加入了服务器游戏的志愿者。我的服务器插件有问题。它通常与我们的网站链接,但链接似乎有缺陷。原因似乎是" ObjectMapper"插件找不到:
[21:20:16] [Thread-8/WARN]: Exception in thread "Thread-8"
[21:20:16] [Thread-8/WARN]: java.lang.NoClassDefFoundError: org/codehaus/jackson/map/ObjectMapper
[21:20:16] [Thread-8/WARN]: at main.java.com.naheulcraft.specific.Ressources.FeatureFunctions$AsynchronousAPISender$APISenderRunnable.run(FeatureFunctions.java:669)
[21:20:16] [Thread-8/WARN]: at java.lang.Thread.run(Unknown Source)
[21:20:16] [Thread-8/WARN]: Caused by: java.lang.ClassNotFoundException: org.codehaus.jackson.map.ObjectMapper
[21:20:16] [Thread-8/WARN]: at java.net.URLClassLoader.findClass(Unknown Source)
[21:20:16] [Thread-8/WARN]: at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101)
[21:20:16] [Thread-8/WARN]: at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86)
[21:20:16] [Thread-8/WARN]: at java.lang.ClassLoader.loadClass(Unknown Source)
[21:20:16] [Thread-8/WARN]: at java.lang.ClassLoader.loadClass(Unknown Source)
[21:20:16] [Thread-8/WARN]: ... 2 more
以下依赖性在pom.xml中,Maven似乎检测到它:
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.11</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
导入中没有错误:
import org.codehaus.jackson.map.ObjectMapper;
[...]
private class APISenderRunnable implements Runnable
{
Map<String, String> params;
APISenderRunnable(Map<String, String> params)
{
this.params = params;
}
public void run()
{
ObjectMapper mapper = new ObjectMapper();
String url = FeatureFunctions.BuildFullUrl(NCPlugin.API_URL, params);
try
{
array = mapper.readTree(new URL(url));
}
catch(Exception e)
{
System.out.println("ERROR, URL BUILDING FAILED OR API IS DOWN.");
}
}
}
但它不起作用。我在互联网上尝试了很多命题,比如更改版本,更改.classpath,改用com.faster.xml.jackson.databind,添加.jar和buildpath&gt;添加外部罐子,清理并构建项目......没有成功。
这是完整的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>com.naheulcraft</groupId>
<artifactId>specific</artifactId>
<url>http://www.naheulcraft.com/</url>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<filtering>true</filtering>
<directory>src</directory>
<includes>
<include>plugin.yml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<!--<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public</url>
</repository>-->
<repository>
<id>codehaus-snapshots</id>
<url>http://snapshots.repository.codehaus.org</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.11</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!--<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.3</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.3</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.3</version>
<type>jar</type>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
</exclusions>
</dependency>-->
<!--<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>LATEST</version>
</dependency>-->
<dependency>
<groupId>com.google.code.google-collections</groupId>
<artifactId>google-collect</artifactId>
<version>snapshot-20080530</version>
<type>jar</type>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<name>NaheulcraftFR-Specific</name>
<version>1.10</version>
</project>
实际的.classpath:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="C:/Users/Florent_2/Desktop/Serveur test Spigot/bukkit.jar"/>
<classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="C:/Users/Florent_2/Desktop/spigot-1.12.2-R0.1-SNAPSHOT-b1577.jar"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="lib" path="C:/Users/Florent_2/Desktop/jackson-mapper-asl-1.9.11.jar"/>
<classpathentry exported="true" kind="lib" path="C:/Users/Florent_2/Desktop/jackson-core-asl-1.9.11.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
提前感谢您的帮助 弗洛伦特
P.S。 :抱歉我的英语不好,我是法国人,我不是说英语的人。 我在英语论坛上写作,因为我希望得到更多的帮助。