我正在Jenkins上部署应用程序,并获得Multiple bindings error
我已经尝试过在我的pom中添加排除项。然后我运行了maven dependency:tree 命令来跟踪是否有其他依赖项正在使用logback,并且没有引用。下面是我运行这个命令logs后的日志。奇怪的是,在我的本地机器上,应用程序成功地构建并启动了。这是我最新的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>
我甚至尝试过一些愚蠢的事情,比如在每个pom中的每个依赖项中添加排除项,但仍然没有任何变化。
<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>
我也试过这种排除法:
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
我不知道还有什么其他的选择,如果有人有任何想法,我会很感激,谢谢。
还添加了此question的排除项,但仍无变更。
2条答案
按热度按时间qeeaahzv1#
我也遇到了同样的问题,但当我添加
swagger-codegen-maven-plugin
时,问题就开始出现了。在创建了mvn dependency:tree
之后,我发现他们也有slf4j-simple-1.7.30.jar
。然后我添加了排除项:eqqqjvef2#
我花了几个小时才解决这个错误,这是我在从IntelliJ为RestController运行JUnitTest时遇到的。我在gradle中尝试了很多排除组合,根据@Guilherme Alencar的响应,以下是对我有效的方法: