我有一个由Maven管理的项目,该项目使用SLF4J-API-1.5.8和Log4J-1.2.14依赖项管理。在运行时,SLF4J需要 slf4j-log4j12-1.5.8.jar 到“桥”输出到log4j。

所以 pom.xml ,我添加了这个依赖性:

  <dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.8</version>
            <type>jar</type>
            <scope>runtime</scope>
        </dependency>
    </dependencies>
  </dependencyManagement>

建筑后(战争:战争), log4j-1.2.14.jarslf4j-api-1.5.8.jar 都添加到 WEB-INF/lib 目录,但我找不到 slf4j-log4j12-1.5.8.jar 内!

然后,我使用“依赖性层次结构”来检查已解决的依赖项,但找不到SLF4J-LOG4J12(因此未打包到 WEB-INF/lib)

这里出了什么问题?

环境:Maven 3.0-Beta1,M2-Eclipse-0.10.0.0.20100209

有帮助吗?

解决方案

依赖关系管理部分是一种集中依赖信息的机制,在依赖关系管理部分中添加依赖关系并不使其成为您项目的依赖性,您仍然需要将其声明为依赖性:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>1.5.8</version>
      <type>jar</type>
      <scope>runtime</scope>
    </dependency>
  </dependencies>
</dependencyManagement>
<dependencies>
  <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
  </dependency>
</dependencies>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top