Slf4j-log4j12 not packaged maven with "runtime" scope

I have a maven managed project with slf4j-api-1.5.8 and log4j-1.2.14 dependencies. At runtime, slf4j requires slf4j-log4j12-1.5.8.jar to output the "bridge" to log4j.

So in pom.xml I add this dependency:

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

After creating (war: war), log4j-1.2.14.jar and slf4j-api-1.5.8.jar are added to the WEB-INF/lib , but I cannot find slf4j-log4j12-1.5.8.jar inside!

Then I use the "Dependency Hierarchy" to check for allowed dependencies, but I can not find slf4j-log4j12 (therefore it is not packaged in WEB-INF/lib )

What is wrong here?

environment: maven 3.0-beta1, m2-eclipse-0.10.0.20100209

+4
source share
1 answer

The dependency management section is a mechanism for centralizing dependency information, adding a dependency in the dependency management section does not make it dependent on your project yourself, you still need to declare it as a dependency:

 <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> 
+4
source

Source: https://habr.com/ru/post/1311401/


All Articles