logger() slf4j error: The method logger() from the type CoreLogger refers to the missing type Logger

logger() slf4j error: The method logger() from the type CoreLogger refers to the missing type Logger

我正在使用 slf4j 导入,我有以下代码:

do {
            if (error) {
                logger().error("Known issue: clicking [" + item + "] had no effect. Retrying...");
            }
            logger().info("Clicking the [" + item + "] menu item...");
            element.click();
            er`

但是 Eclipse 向我抛出以下编译错误:The method logger() from the type CoreLogger refers to the missing type Logger。我已经正确完成了所有导入,同样的代码对我旁边的人来说运行得很好。你对此有什么见解吗?

The method logger() from the type CoreLogger refers to the missing type Logger.

这不是 class 的缺失导入,而是编译时未检索到的 class。 您确定 slf4j jar 位于您项目的 class 路径中吗?
如果是这样,则可能是 IDE 问题:您可以通过在 IDE 之外编译您的项目来识别它(因此在命令行中)。
如果它不起作用:你在编译时没有依赖关系。
如果可行:您应该在 IDE 中寻找解决方案(例如清理并刷新项目配置)