Reputation: 41
I'm deploying application on Jenkins and I'm getting Multiple bindings error
I've already tried adding exclusions to my pom. Then I ran maven dependency:tree command to trace if any other dependency is using logback and there is no reference to that. Here are my logs after running this command logs. The wierd thing is that on my local machine the application builds and starts successfully. This is my latest pom.xml:
<modules>
<module>my-first-module</module>
<module>my-second-module</module>
</modules>
<properties>
<springboot.version>1.4.1.RELEASE</springboot.version>
<postgresql.version>9.4-1200-jdbc41</postgresql.version>
<hsqldb.version>1.8.0.10</hsqldb.version>
<h2.version>1.4.192</h2.version>
<junit.version>4.12</junit.version>
<jwt.version>0.6.0</jwt.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<spring.security>4.1.3.RELEASE</spring.security>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
</parent>
<dependencyManagement>
<dependencies>
<!--spring-boot-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>${springboot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${springboot.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>${springboot.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${springboot.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${spring.security}</version>
</dependency>
<!--JWT-->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>${jwt.version}</version>
</dependency>
<!--lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.10</version>
<scope>provided</scope>
</dependency>
<!--common-module-->
<dependency>
<groupId>com.soft.pgs</groupId>
<artifactId>common</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<!--mapper-->
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>0.7.5</version>
</dependency>
<!--HSQL-->
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>${hsqldb.version}</version>
<scope>test</scope>
</dependency>
<!--H2-->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
<scope>runtime</scope>
</dependency>
<!--test-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<!--swagger-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.4.0</version>
</dependency>
</dependencies>
</dependencyManagement>
I have even tried stupid things like adding exclusions to every dependency in every pom and still no changes.
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
I tried also this exclusions:
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
And even that two combined. I don't know what other options could be, if someone hase any idea, I would appreciate that, thanks.
Added also exclusions from this question and still no changes.
Upvotes: 2
Views: 1840
Reputation: 1285
struggled several hours to resolve this error, which I was getting when running a JUnitTest for a RestController from IntelliJ. I've tried a lot of exclude combinations in gradle, and based on @Guilherme Alencar response, here's what worked for me:
openApiGenerate {
generatorName.set("spring")
validateSpec.set(true)
inputSpec.set("$rootDir/myproj/src/main/resources/api/api.yaml")
outputDir.set("$buildDir/generated/$generator")
modelPackage.set("com.fanduel.loyalty.gateway.generated.models")
apiPackage.set("com.fanduel.loyalty.gateway.generated.controllers")
configOptions.set(
mapOf(
"dateLibrary" to "java8",
"useTags" to "true",
"interfaceOnly" to "true"
)
)
configurations {
all {
exclude(group = "slf4j-simple", module = "slf4j-simple")
}
}
}
configurations.all {
exclude(module = "slf4j-simple")
}
Upvotes: 0
Reputation: 1403
I was facing the same issue but it started to happen when I added the swagger-codegen-maven-plugin
, and after making the mvn dependency:tree
I figure out they had also the slf4j-simple-1.7.30.jar
. Then I added the exclusion to it:
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.3.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
Upvotes: 1