I have a project named P1 which is a spring-boot project.
The pom has already a parent pom, so I decided to use springboot with a bom.
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
This project is then deployed as P1.jar
Then I have a 2nd project named P2.
This project has only 1 dependecy which is the P1 project :
<dependencies>
<dependency>
<groupId>my.company</groupId>
<artifactId>p1</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
Here is an extract of mvn dependency:tree for both project :
P1:
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.4.3.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.4.3.RELEASE:compile
[INFO] | | +- org.apache.tomcat:tomcat-jdbc:jar:8.5.6:compile
[INFO] | | | \- org.apache.tomcat:tomcat-juli:jar:8.5.6:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:4.3.5.RELEASE:compile
[INFO] | +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] | +- org.springframework.data:spring-data-jpa:jar:1.10.6.RELEASE:compile
[INFO] | | \- org.springframework:spring-orm:jar:4.3.5.RELEASE:compile
P2:
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.4.3.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.4.3.RELEASE:compile
[INFO] | | +- org.apache.tomcat:tomcat-jdbc:jar:8.5.6:compile
[INFO] | | | \- org.apache.tomcat:tomcat-juli:jar:8.5.6:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:4.3.5.RELEASE:compile
[INFO] | +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] | +- org.springframework.data:spring-data-jpa:jar:1.10.6.RELEASE:compile
[INFO] | | \- org.springframework:spring-orm:jar:4.2.9.RELEASE:compile
As you can see, the spring-orm dependency differs.
Can someone explains me how this works and how can I fix that ?
At the moment I added the BOM in my 2nd project. But it's not my goal.
I want to be able to import P1 project with its REAL dependencies without having to do anything else or know which bom the project is using.
Related
My project depends on spring-boot-starter-data-mongodb and I just want to upgrade mongodb driver's version. Here is my pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.9</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.5.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
</dependencies>
</project>
Here is final dependency tree:
[INFO] --- maven-dependency-plugin:3.1.2:tree (default-cli) # demo ---
[INFO] com.demo:demo:jar:0.0.1-SNAPSHOT
[INFO] +- org.mongodb:mongodb-driver-sync:jar:4.5.0:compile
[INFO] | +- org.mongodb:bson:jar:4.2.3:compile
[INFO] | \- org.mongodb:mongodb-driver-core:jar:4.2.3:compile
[INFO] \- org.springframework.boot:spring-boot-starter-data-mongodb:jar:2.5.9:compile
[INFO] +- org.springframework.boot:spring-boot-starter:jar:2.5.9:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:2.5.9:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.5.9:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-logging:jar:2.5.9:compile
[INFO] | | +- ch.qos.logback:logback-classic:jar:1.2.10:compile
[INFO] | | | \- ch.qos.logback:logback-core:jar:1.2.10:compile
[INFO] | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.17.1:compile
[INFO] | | | \- org.apache.logging.log4j:log4j-api:jar:2.17.1:compile
[INFO] | | \- org.slf4j:jul-to-slf4j:jar:1.7.33:compile
[INFO] | +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] | +- org.springframework:spring-core:jar:5.3.15:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.3.15:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.28:compile
[INFO] \- org.springframework.data:spring-data-mongodb:jar:3.2.8:compile
[INFO] +- org.springframework:spring-tx:jar:5.3.15:compile
[INFO] +- org.springframework:spring-context:jar:5.3.15:compile
[INFO] | \- org.springframework:spring-aop:jar:5.3.15:compile
[INFO] +- org.springframework:spring-beans:jar:5.3.15:compile
[INFO] +- org.springframework:spring-expression:jar:5.3.15:compile
[INFO] +- org.springframework.data:spring-data-commons:jar:2.5.8:compile
[INFO] \- org.slf4j:slf4j-api:jar:1.7.33:compile
[INFO] ------------------------------------------------------------------------
My question is why bson and mongodb-driver-core's version are still 4.2.3 instead of 4.5.0. mongodb-driver-sync will depends on bson and mongodb-driver-core, and the versions are 4.5.0. Here is the pom of mongodb-driver-sync.
<project>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.5.0</version>
<dependencies>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>bson</artifactId>
<version>4.5.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-core</artifactId>
<version>4.5.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Because spring-boot-starter-parent inherits from spring-boot-dependencies, which defines
<mongodb.version>4.2.3</mongodb.version>
<dependencyManagement>
<!-- ... -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>${mongodb.version}</version>
</dependency>
<!-- ... -->
</dependencyManagement>
You need to override the property in your pom if you want to upgrade it independently:
<mongodb.version>4.5.0</mongodb.version>
Or wait for the Spring Boot 2.7.0 release, which upgrades Mongo to 4.5.0.
I included my library (mylib) as a maven dependency and from then on, this is thrown at runtime:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/logging/log4j/LogManager
at ...
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager
at ...
... 6 more
I tried to exclude the log4j dependency from mylib import, but no change happened.
Excerpt from my pom.xml.
</properties>
<slf4j.version>1.7.7</slf4j.version>
<log4j.version>1.2.17</log4j.version>
<mylib.version>1.0.0</mylib.version>
</properties>
<dependencies>
<dependency>
<groupId>cz.mylib.name</groupId>
<artifactId>mylib</artifactId>
<version>${mylib.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
</dependencies>
Output from mvn dependency:tree
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # name ---
[INFO] cz.project.name.name:name:jar:1.30.0
[INFO] +- com.github.cverges.expect4j:expect4j:jar:1.6:compile
[INFO] | +- org.apache.servicemix.bundles:org.apache.servicemix.bundles.oro:jar:2.0.8_6:compile
[INFO] | +- com.jcraft:jsch:jar:0.1.50:compile
[INFO] | +- commons-net:commons-net:jar:3.3:compile
[INFO] | \- net.sourceforge.tcljava:com.springsource.tcl.lang.jacl:jar:1.4.1:compile
[INFO] | \- net.sourceforge.tcljava:com.springsource.tcl.lang:jar:1.4.1:compile
[INFO] +- commons-cli:commons-cli:jar:1.2:compile
[INFO] +- org.apache.commons:commons-exec:jar:1.3:compile
[INFO] +- commons-io:commons-io:jar:2.4:compile
[INFO] +- commons-lang:commons-lang:jar:2.6:compile
[INFO] +- cz.mylib.name:mylib:jar:1.0.0:compile
[INFO] | +- org.apache.logging.log4j:log4j-api:jar:2.11.2:compile
[INFO] | +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[INFO] | | \- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] | \- com.opencsv:opencsv:jar:4.6:compile
[INFO] | +- org.apache.commons:commons-lang3:jar:3.8.1:compile
[INFO] | +- org.apache.commons:commons-text:jar:1.3:compile
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.9.3:compile
[INFO] | | +- commons-logging:commons-logging:jar:1.2:compile
[INFO] | | \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] | \- org.apache.commons:commons-collections4:jar:4.2:compile
[INFO] +- jlibdiff:jlibdiff:jar:1.01:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.7:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.7:runtime
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.7:runtime
[INFO] +- log4j:log4j:jar:1.2.17:compile
[INFO] \- junit:junit:jar:4.11:test
[INFO] \- org.hamcrest:hamcrest-core:jar:1.3:test
mylib pom.xml
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.11.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.11.2</version>
</dependency>
</dependencies>
CLASSPATH=$APP_HOME/lib/myproject-1.30.0.jar:$APP_HOME/lib/ojdbc6.jar:$APP_HOME/lib/jlibdiff-1.01.jar:$APP_HOME/lib/commons-cli-1.2.jar:$APP_HOME/lib/commons-io-2.4.jar:$APP_HOME/lib/commons-exec-1.3.jar:$APP_HOME/lib/commons-lang-2.6.jar:$APP_HOME/lib/slf4j-api-1.7.7.jar:$APP_HOME/lib/jcl-over-slf4j-1.7.7.jar:$APP_HOME/lib/slf4j-log4j12-1.7.7.jar:$APP_HOME/lib/log4j-1.2.17.jar:$APP_HOME/lib/mylib-1.0.0.jar
The $APP_HOME/lib contains all slf4j and log4j libraries and mylib as well.
My quick quess is, that you have two different versions of log4j on classpath. In dependency tree I see org.apache.logging.log4j:log4j-api:jar:2.11.2, but also log4j:log4j:jar:1.2.17. You have excluded transitional dependency org.apache.logging.log4j:log4j-core from mylib, but log4j-api is still there.
Try to remove the exclusion of org.apache.logging.log4j:log4j-core and also remove log4j:log4j:jar:1.2.17 from project. This way there should be just one version of log4j 2.11.2.
I have the following test dependencies in a maven project where serenity.version is set to 2.0.30
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-junit</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay-webdriver</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
As you can see here all the selenium dependencies of serenity-core-2.0.30 are set to 3.141.59
Running mvn -U dependency:tree -Dincludes=org.seleniumhq.selenium outputs the following
[INFO] --- maven-dependency-plugin:3.0.2:tree (default-cli) # core ---
[INFO] <snip>
[INFO] \- net.serenity-bdd:serenity-junit:jar:2.0.30:test
[INFO] \- net.serenity-bdd:serenity-core:jar:2.0.30:test
[INFO] +- org.seleniumhq.selenium:selenium-server:jar:3.141.59:test
[INFO] | +- org.seleniumhq.selenium:selenium-firefox-driver:jar:3.9.1:test
[INFO] | +- org.seleniumhq.selenium:selenium-ie-driver:jar:3.9.1:test
[INFO] | \- org.seleniumhq.selenium:jetty-repacked:jar:9.4.12.v20180830:test
[INFO] +- org.seleniumhq.selenium:selenium-java:jar:3.9.1:test
[INFO] +- org.seleniumhq.selenium:selenium-api:jar:3.9.1:test
[INFO] +- org.seleniumhq.selenium:selenium-chrome-driver:jar:3.9.1:test
[INFO] +- org.seleniumhq.selenium:selenium-edge-driver:jar:3.9.1:test
[INFO] +- org.seleniumhq.selenium:selenium-remote-driver:jar:3.9.1:test
[INFO] +- org.seleniumhq.selenium:selenium-safari-driver:jar:3.9.1:test
[INFO] +- org.seleniumhq.selenium:selenium-opera-driver:jar:3.9.1:test
[INFO] +- org.seleniumhq.selenium:selenium-support:jar:3.9.1:test
[INFO] \- org.seleniumhq.selenium:htmlunit-driver:jar:2.29.3:test
I have to add the following dependencies to avoid runtime errors - why is version 3.9.1 being used and how do I avoid this?
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>3.141.59</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>3.141.59</version>
<scope>test</scope>
</dependency>
It turns out that spring-boot-dependencies-2.0.3.RELEASE sets the property selenium.version to 3.9.1 and lists all but the selenium-server artifact in it's dependencyManagement section - setting selenium.version in my POM fixed the issue.
i'm following this tutorial https://spring.io/guides/gs/rest-service/ to build a restful application. when i run this app (run as spring boot application) from spring tool suite it throwing error :
Caused by: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:273)
at org.springframework.boot.SpringApplication.<clinit>(SpringApplication.java:190)
at webapp.Application.main(Application.java:9)
... 6 more
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
same error also happen when i tried to use the project initializr (https://start.spring.io/).
my pom.xml is exact like the tutorial :
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>com.rondox.sb.restfulws</groupId>
<artifactId>wawa</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>wawa</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
my dependency tree :
[INFO] --- maven-dependency-plugin:2.10:tree (default-cli) # wawa ---
[INFO] com.rondox.sb.restfulws:wawa:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.5.2.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:1.5.2.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot:jar:1.5.2.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.2.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:1.5.2.RELEASE:compile
[INFO] | | | +- ch.qos.logback:logback-classic:jar:1.1.11:compile
[INFO] | | | | \- ch.qos.logback:logback-core:jar:1.1.11:compile
[INFO] | | | +- org.slf4j:jcl-over-slf4j:jar:1.7.24:compile
[INFO] | | | +- org.slf4j:jul-to-slf4j:jar:1.7.24:compile
[INFO] | | | \- org.slf4j:log4j-over-slf4j:jar:1.7.24:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.17:runtime
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.2.RELEASE:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.11:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.11:compile
[INFO] | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.11:compile
[INFO] | +- org.hibernate:hibernate-validator:jar:5.3.4.Final:compile
[INFO] | | +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] | | \- com.fasterxml:classmate:jar:1.3.3:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.7:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.8.7:compile
[INFO] | +- org.springframework:spring-web:jar:4.3.7.RELEASE:compile
[INFO] | | +- org.springframework:spring-aop:jar:4.3.7.RELEASE:compile
[INFO] | | +- org.springframework:spring-beans:jar:4.3.7.RELEASE:compile
[INFO] | | \- org.springframework:spring-context:jar:4.3.7.RELEASE:compile
[INFO] | \- org.springframework:spring-webmvc:jar:4.3.7.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:4.3.7.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.5.2.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:1.5.2.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.2.RELEASE:test
[INFO] | +- junit:junit:jar:4.12:test
[INFO] | +- org.assertj:assertj-core:jar:2.6.0:test
[INFO] | +- org.mockito:mockito-core:jar:1.10.19:test
[INFO] | | \- org.objenesis:objenesis:jar:2.1:test
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] | +- org.skyscreamer:jsonassert:jar:1.4.0:test
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] | +- org.springframework:spring-core:jar:4.3.7.RELEASE:compile
[INFO] | \- org.springframework:spring-test:jar:4.3.7.RELEASE:test
[INFO] \- com.jayway.jsonpath:json-path:jar:2.2.0:test
[INFO] +- net.minidev:json-smart:jar:2.2.1:test
[INFO] | \- net.minidev:accessors-smart:jar:1.1:test
[INFO] | \- org.ow2.asm:asm:jar:5.0.3:test
[INFO] \- org.slf4j:slf4j-api:jar:1.7.24:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.750 s
[INFO] Finished at: 2017-04-09T12:05:22+07:00
have tried this solution ClassNotFoundException: org.slf4j.LoggerFactory to add the latest jar to the classpath but it giving another error :
SLF4J: Class path contains multiple SLF4J bindings.
please throw some enlightment, i have been struggle for this issue for 3 days.
You have more than one logger in your dependencies and slf4j doesn't know which one to use. You should check Maven's dependency tree to fix it.
logback-classic <-> log4j-over-slf4j <-> jboss-logging (?)
You can exclude Spring Boot Logging (Logback by default) and declare Log4j2 manually:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
after few times of trial and error, i found out my slf4j jar is corrupted. i can see it when i run mvn package command and there's warning.
i renamed the jar, then it will redownload the jar. as soon as the jar not corrupted, then the application face another error. i just followed this source Spring Boot: New Project - UnsatisfiedDependencyException: Error creating bean with name 'methodValidationPostProcessor'
to add hibernate validator in exclusion. after that i can run my app normally. thanks all.
You may use
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
</dependency>
It was happening with me too, I changed the spring-boot version for a previous version and it works.
I changed the 1.5.6-RELEASE to 1.3.5-RELEASE
Add missing Logback JARs into the classpath. The JARs can be found in Maven Central.Following are the two jar files
logback-core-1.0.13.jar
logback-classic-1.0.13.jar
I am trying to upgrade spring-aop from Maven. I tried to delete all Spring files from my .m2 repo, however, when I run mvn dependency:tree I see 3.0.0.RC3 instead of 3.1.1.final...
Dependency tree:
[INFO] com.abercrombie.loyalty:LoyaltyProvider:war:0.0.1-SNAPSHOT
[INFO] +- org.springframework:spring-aop:jar:3.0.0.RC3:compile
[INFO] +- org.springframework:spring-beans:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:3.1.1.RELEASE:compile
[INFO] | \- org.springframework:spring-asm:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-context-support:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:3.1.1.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.springframework:spring-expression:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-jdbc:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:3.1.1.RELEASE:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-web:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-test:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:3.1.1.RELEASE:compile
[INFO] +- com.thoughtworks.xstream:xstream:jar:1.3.1:compile
[INFO] | \- xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] +- com.ibm.db2:db2jcc:jar:2.10.113:compile
[INFO] +- com.ibm.db2:db2jcc_license:jar:2.10.113:compile
[INFO] +- org.hibernate:hibernate-core:jar:3.5.6-Final:compile
[INFO] | +- antlr:antlr:jar:2.7.6:compile
[INFO] | +- commons-collections:commons-collections:jar:3.1:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] | +- javax.transaction:jta:jar:1.1:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.5.8:compile
[INFO] +- org.hibernate:hibernate-annotations:jar:3.5.6-Final:compile
[INFO] | +- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
[INFO] | \- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final:compile
[INFO] +- commons-dbcp:commons-dbcp:jar:1.4:compile
[INFO] | \- commons-pool:commons-pool:jar:1.5.4:compile
[INFO] +- org.slf4j:slf4j-simple:jar:1.5.6:compile
[INFO] +- javassist:javassist:jar:3.12.1.GA:compile
[INFO] +- cglib:cglib:jar:2.2.2:compile
[INFO] | \- asm:asm:jar:3.3.1:compile
[INFO] +- com.sun.xml.bind:jaxb-impl:jar:2.1.12:compile
[INFO] | \- javax.xml.bind:jaxb-api:jar:2.1:compile
[INFO] | +- javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] | \- javax.activation:activation:jar:1.1:compile
[INFO] +- com.sun.jersey:jersey-core:jar:1.11:compile
[INFO] +- com.sun.jersey:jersey-server:jar:1.11:compile
[INFO] \- com.sun.jersey.contribs:jersey-spring:jar:1.11:compile
[INFO] \- com.sun.jersey:jersey-servlet:jar:1.11:compile
POM Dependencies
<spring.version>3.1.1.RELEASE</spring.version>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
how do I get it using 3.1.1.Final?
One of your other dependencies is almost definitely transitively pulling in a different version of spring. I confirmed that if I add a dependency on jersey-spring I get an older version of spring-aop. You can fix it by just adding a dependencyManagement section. To demonstrate the problem, try putting the following into an empty maven project:
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-spring</artifactId>
<version>1.11</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
</dependencies>
</dependencyManagement>
Look at the output of mvn dependency:tree. You will see the correct spring-aop version. Then delete the dependencyManagement section. It will be an older version. Delete the dependency on jersey-spring and you get the correct version of spring-aop again.
My guess would be that you may have dependency declared somewhere else (e.g. dependencyManagement section in this or parent project). Try to run mvn help:effective-pom to see the actual pom and then work from there.
Spring AOP depend on other jar use mvn dependency:tree to see full details . Which jar is dependent on other.