使用maven添加HikariCP导致ClassNotFoundException错误

时间:2018-01-15 17:44:55

标签: java maven hikaricp

启动插件服务器的插件时启用HikariCP时出错。我的.jar中有Hikari阴影。我的pom.xml可以在https://pastebin.com/3vpEzyig

找到
[18:32:48] [Server thread/ERROR]: Error occurred while enabling PvPCraftFactions v1.0.0 (Is it up to date?)
    java.lang.NoClassDefFoundError: com/zaxxer/hikari/HikariConfig
        at com.massivecraft.factions.Settings.loadHikariConfig(Settings.java:411) ~[?:?]
        at com.massivecraft.factions.Settings.load(Settings.java:491) ~[?:?]
        at com.massivecraft.factions.P.loadSettings(P.java:197) ~[?:?]
        at com.massivecraft.factions.P.onEnable(P.java:153) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[server.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [server.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [server.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [server.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [server.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:414) [server.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:378) [server.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:333) [server.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:263) [server.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [server.jar:git-Spigot-db6de12-18fbb24]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]
    Caused by: java.lang.ClassNotFoundException: com.zaxxer.hikari.HikariConfig
        at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_131]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101) ~[server.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[server.jar:git-Spigot-db6de12-18fbb24]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_131]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_131]
        ... 15 more

提前致谢

1 个答案:

答案 0 :(得分:0)

从maven的pom.xml中删除com.zaxxer.hikari包重定位的行,以便识别com/zaxxer/hikari/HikariConfig(以及其他类)。

<relocation>

  <pattern>com.zaxxer.hikari</pattern>
  <shadedPattern>com.massivecraft.factions.shade.com.zaxxer.hikari</shadedPattern>
</relocation>

另见https://docs.microsoft.com/en-us/windows/uwp/launch-resume/suspend-an-app的用法。