我创建了一个 Java Web 应用程序项目。我正在加载一些外部库,这些库还需要一些外部依赖项,这些依赖项不在我的计算机上,需要通过 Maven 下载。因此,我在运行时遇到以下异常:-
异常:java.lang.NoClassDefFoundError:org/slf4j/impl/StaticLoggerBinder
我不知道如何将我的项目(在 Netbeans 中)与 Maven 集成以下载外部依赖项。
有人可以告诉我如何在 netbeans 中使用 maven 从互联网下载依赖项吗?
我的电脑已经安装了maven 3.0.2
谢谢
最佳答案
您缺少SLF4J ,一个标准的日志框架。
您需要 SLF4J api 和实现库,通常是 log4j。并且两者的版本必须契合。这是一个示例配置(将这些添加到您的 pom.xml 中):
<dependency>
<!-- the API -->
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<!-- log4j binding -->
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<!-- redirect any commons-logging calls to slf4j -->
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.6.1</version>
</dependency>
引用:
关于java - 使用 Maven 下载 NetBeans Web 应用程序项目中的外部依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4781016/