簡體   English   中英

java.lang.ClassCastException: org.apache.logging.slf4j.SLF4JLoggerContext 不能轉換為 org.apache.logging.log4j.core.LoggerContext

[英]java.lang.ClassCastException: org.apache.logging.slf4j.SLF4JLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext

我正在嘗試通過 api 創建 SpellChecker 程序,這是我的代碼

拼寫檢查.java

package com.spell;

import org.xeustechnologies.googleapi.spelling.SpellChecker;
import org.xeustechnologies.googleapi.spelling.SpellCorrection;
import org.xeustechnologies.googleapi.spelling.SpellResponse;

public class SpellCheck {

    public static void main(String[] args)
    {

        SpellChecker checker = new SpellChecker();

        SpellResponse spellResponse = checker.check( "helloo worlrd" );

        for( SpellCorrection sc : spellResponse.getCorrections() ) 
            System.out.println( sc.getValue() );

    }
}

依賴項

在此處輸入圖像描述

在此處輸入圖像描述

運行后出現的錯誤:

com.spell.SpellCheck.main(SpellCheck.java:12) 處的線程“main”java.lang.ExceptionInInitializerError 中的異常原因:java.lang.ClassCastException:org.apache.logging.slf4j.SLF4JLoggerContext 無法轉換為 org。 org.apache.log4j.Logger$PrivateManager.getContext(Logger.java:59) 上 org.xeustechnologies 上 org.apache.log4j.Logger.getLogger(Logger.java:41) 上的 apache.logging.log4j.core.LoggerContext。 googleapi.spelling.SpellChecker.(SpellChecker.java:50) ... 還有 1 個

看起來org.xeustechnologies.google.api.spelling.SpellChecker使用 log4j 而您使用的是 slf4j。 嘗試將log4j-over-slf4j添加到類路徑以橋接 log4 以使用 slf4j。

暫無
暫無

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

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