Maven 无法解决 hibernate-c3p0 对 slf4j 的依赖

发布于 2024-07-22 13:38:10 字数 416 浏览 11 评论 0原文

当我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

假情假意假温柔 2024-07-29 13:38:10

slf4j 可能是一个可选依赖项。 您可以使用依赖项插件非常轻松地检查传递依赖项,

mvn dependency:tree

它将向您显示一个树状列表,其中列出了哪些内容依赖于哪些内容。 如果 slf4j 不是 dep,您可以显式添加它。

华泰

It could be that slf4j is an optional dependency. You can check the transitive dependencies very easily using the dependency plugin

mvn dependency:tree

will show you a tree listing of exactly what depends on what. If slf4j is not a dep, you can add it explicity.

HTH

明天过后 2024-07-29 13:38:10

org.slf4j.impl.StaticLoggerBinderNoClassDefFoundError 表示找不到 SLF4J 绑定。 通过传递性,hibernate-c3p0 依赖于 slf4j-api。 但是,如果没有绑定,slf4j-api 就无法运行。 有关详细信息,请参阅 SLF4J 用户手册: www.slf4j.org/manual.html

您只需添加 slf4j-simple、slf4j-log4j12、slf4j-jdk14 或 logback-classic 之一作为依赖项。 前面提到的 SLF4J 手册页应该有详细信息。

The NoClassDefFoundError for org.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.html

You 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文