【发布时间】:2017-02-06 22:38:30
【问题描述】:
我有一个 Spring Boot 应用程序,我正在努力让日志记录与滚动附加器策略一起工作。
这是我的 pom.xml 的相关部分
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.0.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>phoenix</groupId>
<artifactId>phoenix</artifactId>
<version>4.1.0-client-hadoop2</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>20030825.184428</version>
</dependency>
<dependency>
<groupId>org.apache.directory.studio</groupId>
<artifactId>org.apache.commons.pool</artifactId>
<version>1.6</version>
</dependency>
</dependencies>
当我只用 pom.xml 单独运行我的应用程序时,我收到了这个错误:
java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError. See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
我阅读了有关排除的内容,因此我认为我需要将排除添加到启动启动器中,如下所示:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<exclusions>
<exclusion>
<artifactId>log4j-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
然后当我运行它时,我得到了另一个错误:
java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.Log4jLoggerFactory loaded from file:/C:/maven/repo/phoenix/phoenix/4.1.0-client-hadoop2/phoenix-4.1.0-client-hadoop2.jar). If you are using Weblogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml Object of class [org.slf4j.impl.Log4jLoggerFactory] must be an instance of class ch.qos.logback.classic.LoggerContext
所以它是在谈论我猜与凤凰驱动程序的一些冲突,但我不明白为什么。当我加载我的 pom.xml 并查看 Dependency Heirarchy 并查找该 jar 时,它没有列出我可以尝试排除的任何内容。
所以在这一点上我不知道如何继续。
【问题讨论】:
-
该 jar 可能在其中捆绑了一些依赖项。检查 JAR 内部并尝试获取没有捆绑依赖项的版本。我什至无法在maven中找到它。这个 JAR 来自哪里?
标签: spring spring-boot