【问题标题】:Getting java.lang.IllegalStateException: Logback configuration error detected while executing Test class in Spring boot获取 java.lang.IllegalStateException:在 Spring Boot 中执行测试类时检测到 Logback 配置错误
【发布时间】:2020-11-01 07:59:39
【问题描述】:

在 Spring Boot 应用程序中运行测试类时出现异常:

2020-07-12 00:17:51,654 [main] INFO org.jsmart.zerocode.core.utils.RunnerUtils - ### testClass : class GetTest.GetFileTest
Logging system failed to initialize using configuration from 'file:/C:/Users/Desktop/pts-mi-sourcecode/acquiring-api/common-config/target/classes/log4j2-local.xml'
java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.joran.spi.Interpreter@20:13 - no applicable action for [Appenders], current ElementPath  is [[Configuration][Appenders]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@21:73 - no applicable action for [Console], current ElementPath  is [[Configuration][Appenders][Console]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@22:19 - no applicable action for [PatternLayout], current ElementPath  is [[Configuration][Appenders][Console][PatternLayout]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@23:14 - no applicable action for [pattern], current ElementPath  is [[Configuration][Appenders][Console][PatternLayout][pattern]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@27:200 - no applicable action for [RollingFile], current ElementPath  is [[Configuration][Appenders][RollingFile]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@30:26 - no applicable action for [JsonLayout], current ElementPath  is [[Configuration][Appenders][RollingFile][JsonLayout]]

测试类:

import org.jsmart.zerocode.core.domain.JsonTestCase;
import org.jsmart.zerocode.core.domain.TargetEnv;
import org.junit.Test;
import org.junit.runner.RunWith;

import testrunner.ZerocodeSpringBootRunner;

@TargetEnv("application.properties")
@RunWith(ZerocodeSpringBootRunner.class)
public class GetFileTest {
    
     

    @Test
    @JsonTestCase("test_Merchant_Profile.json")
    public void testGETOk(){

    }

}

【问题讨论】:

    标签: java spring spring-boot junit logback


    【解决方案1】:

    您显然已将应用程序配置为使用 Logback 库,但正在尝试使用 Log4j 2 配置。 Logback 不会理解 Log4j 2 配置文件的语法。您要么需要提供 Logback 配置文件,要么将 Logback 依赖项替换为 Log4j 2 依赖项。

    【讨论】:

      猜你喜欢
      • 2018-08-06
      • 2018-12-03
      • 1970-01-01
      • 2019-06-02
      • 2021-05-22
      • 1970-01-01
      • 2016-02-22
      • 2020-04-13
      • 1970-01-01
      相关资源
      最近更新 更多