Maven 无法解决 hibernate-c3p0 对 slf4j 的依赖
当我在 Maven 的 pom.xml 文件中包含 hibernate-c3p0 时,我收到运行时 NoClassDefFoundError 因为它找不到 org .slf4j.impl.StaticLoggerBinder。 我的印象是 Maven 会解决这种依赖性 - 因此如果 c3p0 需要 slf4j,那么 slf4j 将被下载并包含。
我的 pom.xml 文件有:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>3.3.1.GA</version>
</dependency>
When I include hibernate-c3p0
in my Maven's pom.xml
file, I get a runtime NoClassDefFoundError
as it can't find org.slf4j.impl.StaticLoggerBinder
. It was my impression that Maven would resolve this dependency – so if c3p0 requires slf4j, then slf4j would be downloaded and included.
My pom.xml
file has:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>3.3.1.GA</version>
</dependency>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
slf4j 可能是一个可选依赖项。 您可以使用依赖项插件非常轻松地检查传递依赖项,
它将向您显示一个树状列表,其中列出了哪些内容依赖于哪些内容。 如果 slf4j 不是 dep,您可以显式添加它。
华泰
It could be that slf4j is an optional dependency. You can check the transitive dependencies very easily using the dependency plugin
will show you a tree listing of exactly what depends on what. If slf4j is not a dep, you can add it explicity.
HTH
org.slf4j.impl.StaticLoggerBinder
的NoClassDefFoundError
表示找不到 SLF4J 绑定。 通过传递性,hibernate-c3p0 依赖于 slf4j-api。 但是,如果没有绑定,slf4j-api 就无法运行。 有关详细信息,请参阅 SLF4J 用户手册: www.slf4j.org/manual.html您只需添加 slf4j-simple、slf4j-log4j12、slf4j-jdk14 或 logback-classic 之一作为依赖项。 前面提到的 SLF4J 手册页应该有详细信息。
The
NoClassDefFoundError
fororg.slf4j.impl.StaticLoggerBinder
indicates that no SLF4J binding could be found. By transitivity, hibernate-c3p0 depends on slf4j-api. However, slf4j-api cannot function without a binding. See SLF4J user manual for details: www.slf4j.org/manual.htmlYou just need to add one of slf4j-simple, slf4j-log4j12, slf4j-jdk14, or logback-classic as a dependency. The SLF4J manual page mentioned earlier should have the details.