I've tried to follow the other slf4j and other answers from the web to no avail. I think my scenario is a little different.. I started with a maven spring-boot jpa app, all works good. I am working with some company's sdk but it's not maven. They provide a jar and jar-with-dependencies. This package will be com.example:theirlib:jar:1.0
When I install standalone jar, it cannot find required dependencies. I tried to add them to pom but run into unsupported repository layout legacy. The permanent solutions to this looks to be log4j related, without manually installing those jars.
The following artifacts could not be resolved: javax.jms:jms:jar:1.1, com.sun.jdmk:jmxtools:jar:1.2.1, com.sun.jmx:jmxri:jar:1.2.1: Could not transfer artifact javax.jms:jms:jar:1.1 from/to java.net (https://maven-repository.dev.java.net/nonav/repository): Cannot access https://maven-repository.dev.java.net/nonav/repository with type legacy using the available connector factories: BasicRepositoryConnectorFactory: Cannot access https://maven-repository.dev.java.net/nonav/repository with type legacy using the available layout factories: Maven2RepositoryLayoutFactory: Unsupported repository layout legacy -> [Help 1]
But those were just the first build errors so I tried the jar-with-dependencies, which throws multiple slf4j bindings error.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/user/.m2/repository/com/example/theirlib/1.0/theirlib-1.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/user/.m2/repository/ch/qos/logback/logback-classic/1.2.11/logback-classic-1.2.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: slf4j-api 1.6.x (or later) is incompatible with this binding.
SLF4J: Your binding is version 1.5.5 or earlier.
SLF4J: Upgrade your binding to version 1.6.x.
...
I am struggling to find the correct artifacts to put in exclusions, if exclusions even works since the installed jar is bundled w/ dependencies?? This seemed like an easier path to solve than trying to include all the correct dependencies and versions for theirlib in this code. Alternatively, I tried to exclusions with the spring dependency but still fail.
First I looked at the dependency tree:
[INFO] com.crush.sample:demo:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.7.0:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-aop:jar:2.7.0:compile
[INFO] | | +- org.springframework:spring-aop:jar:5.3.20:compile
[INFO] | | \- org.aspectj:aspectjweaver:jar:1.9.7:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.7.0:compile
[INFO] | | +- com.zaxxer:HikariCP:jar:4.0.3:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:5.3.20:compile
[INFO] | +- jakarta.transaction:jakarta.transaction-api:jar:1.3.3:compile
[INFO] | +- jakarta.persistence:jakarta.persistence-api:jar:2.2.3:compile
[INFO] | +- org.hibernate:hibernate-core:jar:5.6.9.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging:jar:3.4.3.Final:compile
[INFO] | | +- net.bytebuddy:byte-buddy:jar:1.12.10:compile
[INFO] | | +- antlr:antlr:jar:2.7.7:compile
[INFO] | | +- org.jboss:jandex:jar:2.4.2.Final:compile
[INFO] | | +- com.fasterxml:classmate:jar:1.5.1:compile
[INFO] | | +- org.hibernate.common:hibernate-commons-annotations:jar:5.1.2.Final:compile
[INFO] | | \- org.glassfish.jaxb:jaxb-runtime:jar:2.3.6:compile
[INFO] | | +- org.glassfish.jaxb:txw2:jar:2.3.6:compile
[INFO] | | +- com.sun.istack:istack-commons-runtime:jar:3.0.12:compile
[INFO] | | \- com.sun.activation:jakarta.activation:jar:1.2.2:runtime
[INFO] | +- org.springframework.data:spring-data-jpa:jar:2.7.0:compile
[INFO] | | +- org.springframework.data:spring-data-commons:jar:2.7.0:compile
[INFO] | | +- org.springframework:spring-orm:jar:5.3.20:compile
[INFO] | | +- org.springframework:spring-context:jar:5.3.20:compile
[INFO] | | | \- org.springframework:spring-expression:jar:5.3.20:compile
[INFO] | | +- org.springframework:spring-tx:jar:5.3.20:compile
[INFO] | | +- org.springframework:spring-beans:jar:5.3.20:compile
[INFO] | | \- org.slf4j:slf4j-api:jar:1.7.36:compile
[INFO] | \- org.springframework:spring-aspects:jar:5.3.20:compile
[INFO] +- com.example:theirlib:jar:1.0:compile // jar with dependencies
[INFO] +- org.postgresql:postgresql:jar:9.4.1208:compile
[INFO] \- org.springframework.boot:spring-boot-starter-test:jar:2.7.0:test
[INFO] +- org.springframework.boot:spring-boot-starter:jar:2.7.0:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:2.7.0:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.7.0:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-logging:jar:2.7.0:compile
[INFO] | | +- ch.qos.logback:logback-classic:jar:1.2.11:compile
[INFO] | | | \- ch.qos.logback:logback-core:jar:1.2.11:compile
[INFO] | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.17.2:compile
[INFO] | | | \- org.apache.logging.log4j:log4j-api:jar:2.17.2:compile
[INFO] | | \- org.slf4j:jul-to-slf4j:jar:1.7.36:compile
[INFO] | +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.30:compile
[INFO] +- org.springframework.boot:spring-boot-test:jar:2.7.0:test
[INFO] +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.7.0:test
[INFO] +- com.jayway.jsonpath:json-path:jar:2.7.0:test
[INFO] | \- net.minidev:json-smart:jar:2.4.8:test
[INFO] | \- net.minidev:accessors-smart:jar:2.4.8:test
[INFO] | \- org.ow2.asm:asm:jar:9.1:test
[INFO] +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile
[INFO] | \- jakarta.activation:jakarta.activation-api:jar:1.2.2:compile
[INFO] +- org.assertj:assertj-core:jar:3.22.0:test
[INFO] +- org.hamcrest:hamcrest:jar:2.2:test
[INFO] +- org.junit.jupiter:junit-jupiter:jar:5.8.2:test
[INFO] | +- org.junit.jupiter:junit-jupiter-api:jar:5.8.2:test
[INFO] | | +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] | | +- org.junit.platform:junit-platform-commons:jar:1.8.2:test
[INFO] | | \- org.apiguardian:apiguardian-api:jar:1.1.2:test
[INFO] | +- org.junit.jupiter:junit-jupiter-params:jar:5.8.2:test
[INFO] | \- org.junit.jupiter:junit-jupiter-engine:jar:5.8.2:test
[INFO] | \- org.junit.platform:junit-platform-engine:jar:1.8.2:test
[INFO] +- org.mockito:mockito-core:jar:4.5.1:test
[INFO] | +- net.bytebuddy:byte-buddy-agent:jar:1.12.10:test
[INFO] | \- org.objenesis:objenesis:jar:3.2:test
[INFO] +- org.mockito:mockito-junit-jupiter:jar:4.5.1:test
[INFO] +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] +- org.springframework:spring-core:jar:5.3.20:compile
[INFO] | \- org.springframework:spring-jcl:jar:5.3.20:compile
[INFO] +- org.springframework:spring-test:jar:5.3.20:test
[INFO] \- org.xmlunit:xmlunit-core:jar:2.9.0:test
And now try many combinations of exclusions:
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.crush.sample</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</exclusion>
<exclusion>
<artifactId>logback-classic</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>theirlib</artifactId>
<version>1.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1208</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
What's the best way to solve this?
if you are using intellij , a tool which i often use is maven helper
this allows analyzing the pom and its dependencies visually ,
for example selecting the slf-api from the leftside will show all the paces where its used , if it is marked in white it means its a compile dependency
P.S
you must make sure "thierlibrary" was not shaded , otherwise you cannot solve it with normal maven exclusions
I resolved this by looking at the exploded bundled jar and brute forcing all the dependencies into my project pom and using the standalone jar. Everything is happy for now..
Related
I have an existing SpringBoot Application that was running with no issue. I then created a Java library—a standalone repository with only static Java code, no main class. My library is deployed as a GitHub Maven package.
I then proceeded with setting up my GitHub packages repository in my local Maven settings and added the dependency to my original SpringBoot application. The import process is successful, my library's Jar is in the classpath and compilation and build are successful.
What happens next is I run the application now, and I get the following stacktrace:
02:36:51.110 [main] DEBUG org.springframework.boot.context.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: [<redacted list of classpath dependencies, including my new library>]
02:36:51.223 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:161)
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:102)
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:68)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:80)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at my.org.transfer.TransferServicesApiApplication.main(TransferServicesApiApplication.java:18)
Process finished with exit code 1
I'm not sure what else to try and a night of Googling lead me nowhere.
This is my application's pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>my.org</groupId>
<artifactId>appname</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency> <!-- my library import -->
<groupId>my.org</groupId>
<artifactId>mylibrary</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.6</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>19.0.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.14</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.2.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-booter</artifactId>
<version>2.22.2</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.4</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.influxdb</groupId>
<artifactId>influxdb-java</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<goalPrefix>formatter</goalPrefix>
<executable>true</executable>
</configuration>
</plugin>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.12.0</version>
</plugin>
</plugins>
</build>
</project>
My library's pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>my.org</groupId>
<artifactId>mylibrary</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
</properties>
<distributionManagement>
<repository>
<id>github</id>
<name>Github Packages</name>
<url>https://maven.pkg.github.com/my-org/library-repo</url>
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-secretsmanager</artifactId>
<version>1.11.793</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>20.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-aws-secrets-manager-config</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.10</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>2.0.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
<version>2.0.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>2.0.7</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.12.0</version>
</plugin>
</plugins>
</build>
</project>
Thanks much.
Edit: set spring-boot-starter-parent version in application pom to match the version in the library pom. No changes.
Edit 2: This is the output of mvn dependency:tree (my library-injected dependency at the bottom):
[INFO] my.org.hopscotchtrading:transfer-services-api:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter:jar:2.3.4.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:2.3.4.RELEASE:compile
[INFO] | | \- org.springframework:spring-context:jar:5.2.9.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.3.4.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-logging:jar:2.3.4.RELEASE:compile
[INFO] | | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] | | | \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.13.3:compile
[INFO] | | | \- org.apache.logging.log4j:log4j-api:jar:2.13.3:compile
[INFO] | | \- org.slf4j:jul-to-slf4j:jar:1.7.30:compile
[INFO] | +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] | +- org.springframework:spring-core:jar:5.2.9.RELEASE:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.2.9.RELEASE:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.26:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.3.4.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:2.3.4.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.3.4.RELEASE:test
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.4.0:test
[INFO] | | \- net.minidev:json-smart:jar:2.3:test
[INFO] | | \- net.minidev:accessors-smart:jar:1.2:test
[INFO] | | \- org.ow2.asm:asm:jar:5.0.4:test
[INFO] | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:test
[INFO] | | \- jakarta.activation:jakarta.activation-api:jar:1.2.2:test
[INFO] | +- org.assertj:assertj-core:jar:3.16.1:test
[INFO] | +- org.hamcrest:hamcrest:jar:2.2:test
[INFO] | +- org.junit.jupiter:junit-jupiter:jar:5.6.2:test
[INFO] | | +- org.junit.jupiter:junit-jupiter-api:jar:5.6.2:test
[INFO] | | | +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] | | | \- org.junit.platform:junit-platform-commons:jar:1.6.2:test
[INFO] | | +- org.junit.jupiter:junit-jupiter-params:jar:5.6.2:test
[INFO] | | \- org.junit.jupiter:junit-jupiter-engine:jar:5.6.2:test
[INFO] | +- org.junit.vintage:junit-vintage-engine:jar:5.6.2:test
[INFO] | | +- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] | | +- org.junit.platform:junit-platform-engine:jar:1.6.2:test
[INFO] | | \- junit:junit:jar:4.13:test
[INFO] | +- org.mockito:mockito-core:jar:3.3.3:test
[INFO] | | +- net.bytebuddy:byte-buddy:jar:1.10.14:compile
[INFO] | | +- net.bytebuddy:byte-buddy-agent:jar:1.10.14:test
[INFO] | | \- org.objenesis:objenesis:jar:2.6:test
[INFO] | +- org.mockito:mockito-junit-jupiter:jar:3.3.3:test
[INFO] | +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] | +- org.springframework:spring-test:jar:5.2.9.RELEASE:test
[INFO] | \- org.xmlunit:xmlunit-core:jar:2.7.0:test
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.3.4.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.3.4.RELEASE:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.11.2:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.11.2:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.11.2:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.3.4.RELEASE:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.38:compile
[INFO] | | +- org.glassfish:jakarta.el:jar:3.0.3:compile
[INFO] | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.38:compile
[INFO] | \- org.springframework:spring-webmvc:jar:5.2.9.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:5.2.9.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:5.2.9.RELEASE:compile
[INFO] +- org.projectlombok:lombok:jar:1.18.12:compile
[INFO] +- io.jsonwebtoken:jjwt:jar:0.9.1:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-databind:jar:2.11.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.11.2:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.11.2:compile
[INFO] +- joda-time:joda-time:jar:2.10.6:compile
[INFO] +- org.jetbrains:annotations:jar:19.0.0:compile
[INFO] +- commons-io:commons-io:jar:2.7:compile
[INFO] +- commons-codec:commons-codec:jar:1.14:compile
[INFO] +- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] +- commons-lang:commons-lang:jar:2.4:compile
[INFO] +- org.springframework:spring-web:jar:5.2.7.RELEASE:compile
[INFO] | \- org.springframework:spring-beans:jar:5.2.9.RELEASE:compile
[INFO] +- org.apache.maven.surefire:surefire-booter:jar:2.22.2:compile
[INFO] | \- org.apache.maven.surefire:surefire-api:jar:2.22.2:compile
[INFO] | \- org.apache.maven.surefire:surefire-logger-api:jar:2.22.2:compile
[INFO] +- commons-beanutils:commons-beanutils:jar:1.9.4:compile
[INFO] | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] +- io.springfox:springfox-swagger2:jar:2.9.2:compile
[INFO] | +- io.swagger:swagger-annotations:jar:1.5.20:compile
[INFO] | +- io.swagger:swagger-models:jar:1.5.20:compile
[INFO] | +- io.springfox:springfox-spi:jar:2.9.2:compile
[INFO] | | \- io.springfox:springfox-core:jar:2.9.2:compile
[INFO] | +- io.springfox:springfox-schema:jar:2.9.2:compile
[INFO] | +- io.springfox:springfox-swagger-common:jar:2.9.2:compile
[INFO] | +- io.springfox:springfox-spring-web:jar:2.9.2:compile
[INFO] | +- com.google.guava:guava:jar:20.0:compile
[INFO] | +- com.fasterxml:classmate:jar:1.5.1:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.30:compile
[INFO] | +- org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile
[INFO] | +- org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile
[INFO] | \- org.mapstruct:mapstruct:jar:1.2.0.Final:compile
[INFO] +- io.springfox:springfox-swagger-ui:jar:2.9.2:compile
[INFO] +- org.influxdb:influxdb-java:jar:2.18:compile
[INFO] | +- com.squareup.retrofit2:retrofit:jar:2.8.1:compile
[INFO] | +- com.squareup.retrofit2:converter-moshi:jar:2.8.1:compile
[INFO] | | \- com.squareup.moshi:moshi:jar:1.8.0:compile
[INFO] | +- org.msgpack:msgpack-core:jar:0.8.20:compile
[INFO] | +- com.squareup.okhttp3:okhttp:jar:3.14.9:compile
[INFO] | | \- com.squareup.okio:okio:jar:1.17.2:compile
[INFO] | \- com.squareup.okhttp3:logging-interceptor:jar:3.14.9:compile
[INFO] \- my.org:mylibrary:jar:0.0.1-SNAPSHOT:compile
[INFO] +- com.amazonaws:aws-java-sdk-secretsmanager:jar:1.11.793:compile
[INFO] | +- com.amazonaws:aws-java-sdk-core:jar:1.11.793:compile
[INFO] | | +- org.apache.httpcomponents:httpclient:jar:4.5.12:compile
[INFO] | | | \- org.apache.httpcomponents:httpcore:jar:4.4.13:compile
[INFO] | | +- software.amazon.ion:ion-java:jar:1.0.2:compile
[INFO] | | \- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.11.2:compile
[INFO] | \- com.amazonaws:jmespath-java:jar:1.11.793:compile
[INFO] +- org.apache.commons:commons-collections4:jar:4.4:compile
[INFO] +- org.springframework.cloud:spring-cloud-aws-secrets-manager-config:jar:2.1.1.RELEASE:compile
[INFO] | \- org.springframework.cloud:spring-cloud-context:jar:1.3.2.RELEASE:compile
[INFO] | \- org.springframework.security:spring-security-crypto:jar:5.3.4.RELEASE:compile
[INFO] \- org.apache.commons:commons-lang3:jar:3.10:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.147 s
[INFO] Finished at: 2020-09-19T13:06:54-05:00
[INFO] ------------------------------------------------------------------------
You're using different versions of spring-boot-starter-parent (2.3.1.RELEASE and 2.3.4.RELEASE) which is probably leading to inconsistent versions where the later or earlier don't have the method. Try using 2.3.4.RELEASE in your application.
[Update]
You're still getting inconsistent versions of org.springframework:* on the classpath:
[INFO] | \- org.springframework:spring-webmvc:jar:5.2.9.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:5.2.9.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:5.2.9.RELEASE:compile
...
[INFO] +- org.springframework:spring-web:jar:5.2.7.RELEASE:compile
In your application pom.xml remove the explicit dependency from
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.2.7.RELEASE</version>
</dependency>
and any other dependency that is specified in the parent so you get all 5.2.9 versions in the dependency output.
Finally, there is discussion like here about requiring specific versions for Spring Boot and the latest version of spring-cloud-aws-secrets-manager-config is 2.2.4.RELEASE which makes me think your library's POM needs to be updated to use the latest.
Collegues, i have subproject utils in my multimodule project. The pom looks like:
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<artifactId>parent</artifactId>
<groupId>com.comp.kort</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>utils</artifactId>
<dependencies>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${project.build.sourceJdk}</source>
<target>${project.build.targetJdk}</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
I run command mvn clean install and utils-1.0-SNAPSHOT.jar is created in the local maven repository.
After that i add next dependency into pom of another subproject
<dependency>
<groupId>com.comp.kort</groupId>
<artifactId>utils</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
But when i add import com.comp.kort to classes of my second subproject i receive Can't resolve symbol 'kort'.
What should i to import com.comp.kort in the second subproject correctly?
mvn dependency:tree on my second subproject shows:
[INFO] com.comp.kort:kort-sp-integration:jar:1.0-SNAPSHOT
[INFO] +- org.springframework.batch:spring-batch-core:jar:3.0.7.RELEASE:compile
[INFO] | +- com.ibm.jbatch:com.ibm.jbatch-tck-spi:jar:1.0:compile
[INFO] | | \- javax.batch:javax.batch-api:jar:1.0:compile
[INFO] | +- com.thoughtworks.xstream:xstream:jar:1.4.7:compile
[INFO] | | +- xmlpull:xmlpull:jar:1.1.3.1:compile
[INFO] | | \- xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] | +- org.codehaus.jettison:jettison:jar:1.2:compile
[INFO] | +- org.springframework.batch:spring-batch-infrastructure:jar:3.0.7.RELEASE:compile
[INFO] | | \- org.springframework.retry:spring-retry:jar:1.1.0.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:4.0.5.RELEASE:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework:spring-beans:jar:4.0.5.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:4.0.5.RELEASE:compile
[INFO] | | \- org.springframework:spring-expression:jar:4.0.5.RELEASE:compile
[INFO] | +- org.springframework:spring-core:jar:4.0.5.RELEASE:compile
[INFO] | \- org.springframework:spring-tx:jar:4.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-jdbc:jar:4.2.6.RELEASE:compile
[INFO] +- org.apache.commons:commons-dbcp2:jar:2.1.1:compile
[INFO] | +- org.apache.commons:commons-pool2:jar:2.4.2:compile
[INFO] | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- commons-io:commons-io:jar:2.2:compile
[INFO] +- log4j:log4j:jar:1.2.17:compile
[INFO] +- com.microsoft.sqlserver:sqljdbc4:jar:4.2:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.4:compile
[INFO] +- junit:junit:jar:4.12:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- com.sun.mail:javax.mail:jar:1.5.5:compile
[INFO] | \- javax.activation:activation:jar:1.1:compile
[INFO] \- com.comp.kort:utils:jar:1.0-SNAPSHOT:compile
It seems <scope>provided</scope> is not right, and you can remove it.
Provided is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.
You can see here
After executing mvn dependency:tree, I got the following output:
[INFO] stpr:stpr:war:1.0
[INFO] +- org.jboss.spec:jboss-javaee-6.0:pom:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.annotation:jboss-annotations-api_1.1_spec:jar:
1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.resource:jboss-connector-api_1.5_spec:jar:1.0.
0.Final:provided
[INFO] | +- org.jboss.spec.javax.ejb:jboss-ejb-api_3.1_spec:jar:1.0.0.Final:pro
vided
[INFO] | | \- javax.xml:jaxrpc-api:jar:1.1:provided
[INFO] | +- org.jboss.spec.javax.el:jboss-el-api_2.2_spec:jar:1.0.0.Final:provi
ded
[INFO] | +- org.jboss.spec.javax.interceptor:jboss-interceptors-api_1.1_spec:ja
r:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.security.jacc:jboss-jacc-api_1.4_spec:jar:1.0.
0.Final:provided
[INFO] | +- org.jboss.spec.javax.enterprise.deploy:jboss-jad-api_1.2_spec:jar:1
.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.security.auth.message:jboss-jaspi-api_1.0_spec
:jar:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.xml.registry:jboss-jaxr-api_1.0_spec:jar:1.0.0
.Final:provided
[INFO] | +- org.jboss.spec.javax.jms:jboss-jms-api_1.1_spec:jar:1.0.0.Final:pro
vided
[INFO] | +- org.jboss.spec.javax.servlet.jsp:jboss-jsp-api_2.2_spec:jar:1.0.0.F
inal:provided
[INFO] | +- org.jboss.spec.javax.servlet:jboss-servlet-api_3.0_spec:jar:1.0.0.F
inal:provided
[INFO] | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar
:1.0.0.Final:provided
[INFO] | +- org.jboss.spec.javax.xml.bind:jboss-jaxb-api_2.2_spec:jar:1.0.0.Fin
al:provided
[INFO] | +- org.jboss.spec.javax.xml.rpc:jboss-jaxrpc-api_1.1_spec:jar:1.0.0.Fi
nal:provided
[INFO] | +- org.jboss.spec.javax.xml.soap:jboss-saaj-api_1.3_spec:jar:1.0.0.Fin
al:provided
[INFO] | +- org.jboss.spec.javax.xml.ws:jboss-jaxws-api_2.2_spec:jar:1.0.0.Fina
l:provided
[INFO] | +- javax.activation:activation:jar:1.1:provided
[INFO] | +- javax.enterprise:cdi-api:jar:1.0-SP4:provided
[INFO] | +- com.sun.faces:jsf-api:jar:2.0.3-b05:provided
[INFO] | +- javax.inject:javax.inject:jar:1:provided
[INFO] | +- javax.jws:jsr181-api:jar:1.0-MR1:provided
[INFO] | +- javax.mail:mail:jar:1.4.2:provided
[INFO] | +- javax.servlet:jstl:jar:1.2:provided
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Fin
al:provided
[INFO] | +- org.jboss.resteasy:jaxrs-api:jar:2.1.0.GA:provided
[INFO] | +- stax:stax-api:jar:1.0.1:provided
[INFO] | \- javax.validation:validation-api:jar:1.0.0.GA:provided
[INFO] \- javax.transaction:javax.transaction-api:jar:1.2-b03:compile
My question is why javax.transaction-api:jar:1.2-b03:compile were excluded? I didn't specify any exclusion explicitly. What's wrong?
The pom.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>gr</groupId>
<artifactId>ar</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>nm</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
<version>1.2-b03</version>
</dependency>
</dependencies>
<profiles>
<!-- profiles here -->
</profiles>
</project>
The output does not show any exclusion for the dependency. In fact, if the dependency were excluded, it would not have been shown in the dependency tree. By looking at the tree, the dependency is shown in the last line:
[INFO] \- javax.transaction:javax.transaction-api:jar:1.2-b03:compile
Maybe you need to update your maven project to reload the dependencies.
Geting this error on: mvn package
It fails to build every time with the same error, I've tried renaming the artifact, as well as changing dependencies for build in the pom file. Please see more details below:
Any help would be very much appreciated.
error:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.599 s
[INFO] Finished at: 2014-09-29T14:49:45+01:00
[INFO] Final Memory: 33M/379M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.1.7.RELEASE:repackage (default) on project compiled: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.1.7.RELEASE:repackage failed: For artifact {com.phil-hudson:compiled:1.0-SNAPSHOT:war}: An attached artifact must have a different ID than its corresponding main artifact. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
Process finished with exit code 1
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.phil-hudson</groupId>
<artifactId>compiled</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<!-- Generic properties -->
<java.version>1.8</java.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.5.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-jaxrs_2.10</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.8-b01</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2-promoted-b65</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<version>8.0.12</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.1.7.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warName>disney-product-feed</warName>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<url>http://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>http://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
mvn dependency:tree
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.1.5.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:1.1.5.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot:jar:1.1.5.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.1.5.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:1.1.5.RELEASE:compile
[INFO] | | | +- org.slf4j:jcl-over-slf4j:jar:1.7.7:compile
[INFO] | | | +- org.slf4j:jul-to-slf4j:jar:1.7.7:compile
[INFO] | | | +- org.slf4j:log4j-over-slf4j:jar:1.7.7:compile
[INFO] | | | \- ch.qos.logback:logback-classic:jar:1.1.2:compile
[INFO] | | | \- ch.qos.logback:logback-core:jar:1.1.2:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.13:runtime
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.1.5.RELEASE:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:7.0.54:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:7.0.54:compile
[INFO] | | \- org.apache.tomcat.embed:tomcat-embed-logging-juli:jar:7.0.54:compile
[INFO] | +- org.hibernate:hibernate-validator:jar:5.0.3.Final:compile
[INFO] | | +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging:jar:3.1.1.GA:compile
[INFO] | | \- com.fasterxml:classmate:jar:1.0.0:compile
[INFO] | +- org.springframework:spring-core:jar:4.0.6.RELEASE:compile
[INFO] | \- org.springframework:spring-webmvc:jar:4.0.6.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:4.0.6.RELEASE:compile
[INFO] +- org.springframework:spring-web:jar:4.0.6.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:4.0.6.RELEASE:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework:spring-beans:jar:4.0.6.RELEASE:compile
[INFO] | \- org.springframework:spring-context:jar:4.0.6.RELEASE:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.3.3:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.3.3:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.3.3:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.3.2:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.1.5.RELEASE:compile
[INFO] | +- junit:junit:jar:4.11:compile
[INFO] | +- org.mockito:mockito-core:jar:1.9.5:compile
[INFO] | | \- org.objenesis:objenesis:jar:1.0:compile
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:compile
[INFO] | \- org.springframework:spring-test:jar:4.0.6.RELEASE:compile
[INFO] +- javax.inject:javax.inject:jar:1:compile
[INFO] +- com.wordnik:swagger-jaxrs_2.10:jar:1.3.2:compile
[INFO] | +- org.scala-lang:scala-library:jar:2.10.0:compile
[INFO] | +- com.wordnik:swagger-core_2.10:jar:1.3.2:compile
[INFO] | | +- commons-lang:commons-lang:jar:2.4:compile
[INFO] | | +- org.slf4j:slf4j-api:jar:1.7.7:compile
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-scala_2.10:jar:2.1.5:compile
[INFO] | | | +- com.thoughtworks.paranamer:paranamer:jar:2.3:compile
[INFO] | | | \- org.scala-lang:scala-reflect:jar:2.10.0:compile
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-jsonSchema:jar:2.1.0:compile
[INFO] | | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.0.0:compile
[INFO] | | | \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.0.0:compile
[INFO] | | +- com.wordnik:swagger-annotations:jar:1.3.2:compile
[INFO] | | +- org.json4s:json4s-ext_2.10:jar:3.2.4:compile
[INFO] | | | +- joda-time:joda-time:jar:2.3:compile
[INFO] | | | \- org.joda:joda-convert:jar:1.2:compile
[INFO] | | +- org.json4s:json4s-native_2.10:jar:3.2.4:compile
[INFO] | | | \- org.json4s:json4s-core_2.10:jar:3.2.4:compile
[INFO] | | | +- org.json4s:json4s-ast_2.10:jar:3.2.4:compile
[INFO] | | | \- org.scala-lang:scalap:jar:2.10.0:compile
[INFO] | | | \- org.scala-lang:scala-compiler:jar:2.10.0:compile
[INFO] | | \- org.json4s:json4s-jackson_2.10:jar:3.2.4:compile
[INFO] | +- javax.ws.rs:jsr311-api:jar:1.1.1:compile
[INFO] | \- org.reflections:reflections:jar:0.9.8:compile
[INFO] | +- com.google.guava:guava:jar:11.0.2:compile
[INFO] | | \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] | +- javassist:javassist:jar:3.12.1.GA:compile
[INFO] | \- dom4j:dom4j:jar:1.6.1:compile
[INFO] | \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
[INFO] | \- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] +- com.sun.xml.bind:jaxb-core:jar:2.2.8-b01:compile
[INFO] | +- javax.xml.bind:jaxb-api:jar:2.2.9:compile
[INFO] | \- com.sun.istack:istack-commons-runtime:jar:2.16:compile
[INFO] +- com.sun.xml.bind:jaxb-impl:jar:2.2-promoted-b65:compile
[INFO] +- org.apache.tomcat:tomcat-servlet-api:jar:8.0.12:compile
[INFO] \- javax.servlet.jsp:jsp-api:jar:2.1:provided
As Dimitri suggested, I solved this by adding classifier to spring-boot-maven-plugin:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>boot</classifier>
</configuration>
</plugin>
Looks like a bug in spring-boot-maven-plugin together with your version of Maven.
As far as I can tell, Maven knows that the WAR plugin will generate the file target/compiled-1.0-SNAPSHOT.war. when it asks the spring-boot-maven-plugin for its output, it will get the same name. Since Maven doesn't know what the plugin does, it will assume that both are configured to create the same output file and stop since that can't be what you want (the files will overwrite each other).
Try with the latest version of Maven or file a bug against the spring-boot-maven-plugin. Let them know which version of Maven you're using.
I am currently facing the same issue.
However, providing the required parameter finalName, I can see that the .war file is well boot-ified.
Please note that I still encounter the error message in both cases (with and without the finalName).
Here is the link to the issue I opened on the Spring Boot project: https://github.com/spring-projects/spring-boot/issues/2060
All that is required is to include a <finalName> tag in the build section.
<build>
<finalName>myJar</finalName>
</build>
I have a project that use both dependencies independently: BoneCP and Hibernate. But thanks to SLF4J and its version conflicts it does not work because BoneCP requires SLF4J 1.5 and Hibernate requires SLF4j 1.6. As you know it is not possible to important two different versions of the same dependency in your pom.xml. So what can I do to workaround this amazing SLF4J side-effect???
The error I get is the infamous:
SLF4J: The requested version 1.5.10 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
I would need to add this, but same dependency with two different versions is not allowed:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.2</version>
<scope>provided</scope>
</dependency>
Maven dependency tree:
[INFO] [dependency:tree {execution: default-cli}]
[INFO] org.mentawai:menta:war:1.0.5-SNAPSHOT
[INFO] +- javax.servlet.jsp:jsp-api:jar:2.0:provided
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided
[INFO] +- javax.activation:activation:jar:1.1:compile
[INFO] +- javax.mail:mail:jar:1.4:compile
[INFO] +- javax.persistence:persistence-api:jar:1.0:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.5.10:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.5.10:compile
[INFO] | \- log4j:log4j:jar:1.2.14:compile
[INFO] +- org.hibernate:hibernate-core:jar:3.6.7.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] | +- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
[INFO] | \- javax.transaction:jta:jar:1.1:compile
[INFO] +- javassist:javassist:jar:3.12.1.GA:compile
[INFO] +- junit:junit:jar:4.8.1:test
[INFO] +- c3p0:c3p0:jar:0.9.1.2:compile
[INFO] +- com.h2database:h2:jar:1.2.138:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.13:compile
[INFO] +- me.soliveirajr:mentawai:jar:2.3.3-SNAPSHOT:compile
[INFO] | +- net.sf.json-lib:json-lib:jar:jdk15:2.3:compile
[INFO] | | +- commons-beanutils:commons-beanutils:jar:1.8.0:compile
[INFO] | | +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] | | \- net.sf.ezmorph:ezmorph:jar:1.0.6:compile
[INFO] | +- org.jdom:jdom:jar:1.1:compile
[INFO] | +- com.thoughtworks.xstream:xstream:jar:1.3.1:compile
[INFO] | | \- xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] | +- org.ajaxtags:ajaxtags:jar:1.2-beta3:compile
[INFO] | | +- javax.servlet:jstl:jar:1.0.6:compile
[INFO] | | +- taglibs:standard:jar:1.0.6:compile
[INFO] | | \- net.htmlparser:jericho-html:jar:2.1:compile
[INFO] | +- jgroups:jgroups-all:jar:2.2.9.1:compile
[INFO] | +- me.soliveirajr:menta-container:jar:0.9.8:compile
[INFO] | +- me.soliveirajr:menta-bean:jar:1.1.1:compile
[INFO] | +- me.soliveirajr:menta-regex:jar:0.9.5:compile
[INFO] | +- org.beanshell:bsh:jar:2.0b4:compile
[INFO] | +- com.jolbox:bonecp:jar:0.7.1.RELEASE:compile
[INFO] | | \- com.google.guava:guava:jar:r08:compile
[INFO] | +- velocity:velocity-dep:jar:1.4:compile
[INFO] | +- commons-fileupload:commons-fileupload:jar:1.2.2:compile
[INFO] | +- commons-io:commons-io:jar:1.3.2:compile
[INFO] | +- net.tanesha.recaptcha4j:recaptcha4j:jar:0.0.7:compile
[INFO] | \- commons-dbcp:commons-dbcp:jar:1.4:compile
[INFO] | \- commons-pool:commons-pool:jar:1.5.4:compile
[INFO] +- commons-lang:commons-lang:jar:2.5:compile
[INFO] \- asm:asm:jar:3.2:compile
The link provided in the error message, "http://www.slf4j.org/codes.html#version_mismatch", states:
An SLF4J binding designates an artifact such as slf4j-jdk14.jar or
slf4j-log4j12.jar used to bind slf4j to an underlying logging
framework, say, java.util.logging or log4j. Mixing mixing different
versions of slf4j-api.jar and SLF4J binding can cause problems. For
example, if you are using slf4j-api-1.6.6.jar, then you should also
use slf4j-simple-1.6.6.jar, using slf4j-simple-1.5.5.jar will not
work.
NOTE From the client's perspective all versions of slf4j-api are
compatible. Client code compiled with slf4j-api-N.jar will run
perfectly fine with slf4j-api-M.jar for any N and M. You only need to
ensure that the version of your binding matches that of the
slf4j-api.jar. You do not have to worry about the version of
slf4j-api.jar used by a given dependendency in your project. You can
always use ANY version of slf4j-api.jar, and as long as the version of
slf4j-api.jar and its binding match, you should be fine.
Given that all versions of slf4j-api are interchangeable from the clients perspective, in the scenario where different versions of slf4j-api and its binding e.g. slf4j-log4j12 are pulled in, explicitly declare them as dependencies in your POM as follows:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.25</version>
</dependency>
Here I am assuming that you do not actually need to declare slf4j-api and slf4j-log4j12 in the provided scope.
See also Introduction to the Dependency Mechanism which states:
Dependency mediation - this determines what version of a dependency
will be used when multiple versions of an artifact are encountered.
Currently, Maven 2.0 only supports using the "nearest definition"
which means that it will use the version of the closest dependency to
your project in the tree of dependencies. You can always guarantee a
version by declaring it explicitly in your project's POM.
Just exclude 1.5.10 version of SLF4J
<dependency>
<groupId>...</groupId>
<artifactId>BoneCP</artifactId>
<version>...</version>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.10</version>
</exclusion>
</exclusions>
</dependency>