Maven doesn't download a slf4j dependency slf4j-log4j12 - spring

I try to use
slf4j-log4j12
library, but maven doesn't download the jar. My local .m2 repository shows
enter image description here
I'm using Apache Maven 3.5.4 with Java version: 11.0.15. The dependencies in pom.xml:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-reload4j</artifactId>
<version>2.0.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>2.0.3</version>
<type>pom</type>
<scope>test</scope>
</dependency>
What could be the problem? I'm behind corporate firewall and use JFrog antifactory.
I added maven2 repo to pom.xml. Tried Invalidate Cache in IntelliJ and other cleanup I could think of.

Related

How to stop Maven from downloading all historical versions of aws-java-sdk?

I am using Maven to download aws-java-sdk dependency for version 1.11.23, though in Maven repository I find all historical versions till most recent ones; i.e. aws-java-sdk-sqs downloaded versions (1.9.0 to 1.11.642) any idea why is that and how can I limit to only the version specified for aws-java-sdk artifact?
This "dependency loop" is a problem with some older versions of aws-lambda-java-events, which is probably a dependency of your dependency.
Try updating or your dependencies to the latest, or overriding aws-lambda-java-events to at least 2.2.7:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>2.2.7</version>
</dependency>
For me, After specifying the BOM of AWS SDK in the dependencyManagement section & the version I would like to use, The historical downloads were stopped. Below are my dependencies.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>1.10.6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-dynamodb</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
I created a project (with Maven 3.5.4) with just:
<project ... >
....
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.23</version>
</dependency>
</dependencies>
</project>
All of ~/.m2/repository/com/amazonaws/* (as declared in aws-java-sdks POM) contain just the sub-directory /1.11.23.
UPDATE
To exclude dependencies of your dependencies see Introduction to the Dependency Mechanism, Transitive Dependencies:
Excluded dependencies - If project X depends on project Y, and project Y depends on project Z, the owner of project X can explicitly exclude project Z as a dependency, using the "exclusion" element.

Maven Dependency's dependency

In my project I have slf4j-log4j12
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.25</version>
<scope>test</scope>
</dependency>
This version uses log4j 1.2.17. The log4j latest update is 2.11.1.
How can I make my maven project to force use the latest log4j i.e. 2.11.1 version?
Be aware that log4j version 2 is completely incompatible with log4j version 1. You cannot replace like that those version.
To use log4j-2 as backend for slf4j, you will need to replace this dependency by another.
From the page in log4j 2 site, the dependency is linked to the version of slf4j
In your use case, (sf4j 1.7) it is this one:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.11.1</version>
<scope>test</scope>
</dependency>
for slf4j 1.8+ it will be this one:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j18-impl</artifactId>
<version>2.11.1</version>
<scope>test</scope>
</dependency>

Eclipse plugin- Maven transitive dependency issue

I am facing issue with velocity jar issue. As one of the eclipse plugin dependent on CXF bundle.
jar dependency defined in pom.xml as below,
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle</artifactId>
<version>2.7.5</version>
</dependency>
another eclipse plugin dependent on custom bundle jar which has
jar dependency defined in pom.xml as below,
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
On runtime I am geting issue as,
Could not find Velocity template file: org/apache/cxf/tools/wsdlto/frontend/jaxws/template/build.vm
To identify the issue I run the command,
mvn dependency:tree -Dverbose
This shows maven omitting velocity jar from cxf as it loads another velocity in classpath.
How to resolve this jar dependency ?
use the <exclusions> tag for the dependency you not want:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle</artifactId>
<version>2.7.5</version>
<exclusions>
<exclusion>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<exclusion>
<exclusions>
</dependency>

Stop downloading jar form Repository Maven

In my Maven Project I have dependency for
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.1</version>
</dependency>
But the downloaded jar is corrupted or it has problem so my application fails. I have a working jar in my hard. So I want to add that instead of downloading form repo. I used this to do that,
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/xalan-xalan-2.7.1.jar</systemPath>
</dependency>
But didn't work :(

slf4j-log4j12 not packaged by maven with "runtime" scope

I have a project managed by maven with slf4j-api-1.5.8 and log4j-1.2.14 dependencies.
At runtime, slf4j needs slf4j-log4j12-1.5.8.jar to "bridge" output 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 building (war:war) , log4j-1.2.14.jar and slf4j-api-1.5.8.jar are both added to WEB-INF/lib directory , but I cannot find slf4j-log4j12-1.5.8.jar within!
I then use "Dependency Hierarchy" to check the resolved dependencies , but cannot find slf4j-log4j12 (so it's not packaged into WEB-INF/lib)
What's going wrong here?
environment : maven 3.0-beta1 , m2-eclipse-0.10.0.20100209
The dependency management section is a mechanism for centralizing dependency information, adding a dependency in the dependency management section doesn't make it a dependency of your project by itself, you still need to declare it as 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>

Resources