java.lang.LinkageError: attempted duplicate class definition

java.lang.LinkageError: attempted duplicate class definition

为什么会出现错误,我该如何解决?

[02:13:02] [pool-4-thread-2/WARN]: Exception in thread "pool-4-thread-2" 
[02:13:02] [pool-4-thread-2/WARN]: java.lang.LinkageError: loader (instance of  org/bukkit/plugin/java/PluginClassLoader): attempted  duplicate class definition for name: "com/mongodb/client/model/Filters"
[02:13:02] [pool-4-thread-2/WARN]:  at java.lang.ClassLoader.defineClass1(Native Method)
[02:13:02] [pool-4-thread-2/WARN]:  at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
[02:13:02] [pool-4-thread-2/WARN]:  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
[02:13:02] [pool-4-thread-2/WARN]:  at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
[02:13:02] [pool-4-thread-2/WARN]:  at java.net.URLClassLoader.access0(URLClassLoader.java:73)
[02:13:02] [pool-4-thread-2/WARN]:  at java.net.URLClassLoader.run(URLClassLoader.java:368)
[02:13:02] [pool-4-thread-2/WARN]:  at java.net.URLClassLoader.run(URLClassLoader.java:362)
[02:13:02] [pool-4-thread-2/WARN]:  at java.security.AccessController.doPrivileged(Native Method)
[02:13:02] [pool-4-thread-2/WARN]:  at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
[02:13:02] [pool-4-thread-2/WARN]:  at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101)
[02:13:02] [pool-4-thread-2/WARN]:  at org.bukkit.plugin.java.JavaPluginLoader.getClassByName(JavaPluginLoader.java:195)
[02:13:02] [pool-4-thread-2/WARN]:  at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:97)
[02:13:02] [pool-4-thread-2/WARN]:  at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86)
[02:13:02] [pool-4-thread-2/WARN]:  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[02:13:02] [pool-4-thread-2/WARN]:  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[02:13:02] [pool-4-thread-2/WARN]:  at me.franzsan.data.mongo.MongoCharacter.existsCharacter(MongoCharacter.java:109)
[02:13:02] [pool-4-thread-2/WARN]:  at me.franzsan.data.mongo.MongoCharacter.lambda$loadCharacter[=10=](MongoCharacter.java:44)
[02:13:02] [pool-4-thread-2/WARN]:  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[02:13:02] [pool-4-thread-2/WARN]:  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[02:13:02] [pool-4-thread-2/WARN]:  at java.lang.Thread.run(Thread.java:745)

这是导致错误的行

FindIterable cursor = connection.getCharacters().find(Filters.eq("uuid", uuid));

然后还有这个。它来自另一个模块,两者都应该同时异步执行(或者一个接一个地执行,因为我认为现在我只有一个线程)。这个工作没有错误。

FindIterable cursor = connection.getPlayers().find(Filters.eq("uuid", id));

Filters.eq 是一个静态方法。

两者使用相同

ExecutorService pool = Executors.newCachedThreadPool();

我觉得我缺乏关键知识,但我不知道去哪里找。

duplicate class definition for name 说明了一切。似乎您在类路径 com.mongodb.client 下的插件中复制了 mongodb 驱动程序,就像在其他插件中一样,并且您是 运行 同一服务器上的两个插件。这会导致冲突,因为您尝试使用完全相同的类路径加载 2 类。