gpt4 book ai didi

java - 未找到 HikariCP LoggerFactory 类定义

转载 作者:太空宇宙 更新时间:2023-11-04 14:21:09 26 4
gpt4 key购买 nike

我已经从 http://search.maven.org/#search%7Cga%7C1%7Chikaricp 下载了 HikariCP JAR (第五行)并将其放置在我的构建路径中。如果你打电话

HikariDataSource ds = new HikariDataSource();

你得到了异常:

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.zaxxer.hikari.HikariConfig.<clinit>(HikariConfig.java:45)
at com.josevemon.microserver.App.<init>(App.java:41)
at com.josevemon.microserver.App.main(App.java:16)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 3 more

根据此处的评论:https://stackoverflow.com/a/25114022/555690 ,

I don't know what environment you're developing in, IDE or whatever, but this is a simple classpath issue where the HikariCP jar is not in the classpath at runtime. Clearly it was in the path at compile time or you wouldn't have gotten this far.

因此 HikariCP 在编译时位于我的路径中,但不在运行时。那么,我如何在运行时获得它呢?我正在使用 Eclipse Luna。

最佳答案

您需要在类路径中包含以下 slf4j jar:

  • slf4j-jdk14-1.7.10.jar
  • slf4j-api-1.7.22.jar

我使用maven,因此通过将slf4j-jdk14-1.7.10.jar添加到我的pom文件中,它会自动添加slf4j-api-1.7.22.jar。根据您的情况,您可以从此处下载 jar 文件:

http://central.maven.org/maven2/org/slf4j/slf4j-jdk14/1.7.10/ http://central.maven.org/maven2/org/slf4j/slf4j-api/1.7.22/

关于java - 未找到 HikariCP LoggerFactory 类定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27175146/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com