簡體   English   中英

獲取 java.lang.IllegalStateException:在 Spring 啟動中執行測試 class 時檢測到 Logback 配置錯誤

[英]Getting java.lang.IllegalStateException: Logback configuration error detected while executing Test class in Spring boot

在 spring 啟動應用程序中運行測試 class 時出現異常:

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]]

測試 Class:

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(){

    }

}

您顯然已將應用程序配置為使用 Logback 庫,但正在嘗試使用 Log4j 2 配置。 Logback 無法理解 Log4j 2 配置文件的語法。 您要么需要提供 Logback 配置文件,要么將 Logback 依賴項替換為 Log4j 2 個依賴項。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM