"的logback经典"问题:无法在ch.qos.logback包中访问术语classic

时间:2016-06-20 03:47:53

标签: java scala logging logback

我使用"ch.qos.logback" % "logback-classic" % "1.1.7"作为依赖项(在我的scala + sbt项目中)并使用记录器:val internalLogger = LoggerFactory.getLogger(this.getClass)

我收到以下错误:

[error] missing or invalid dependency detected while loading class file 'Logging.class'.
[error] Could not access term classic in package ch.qos.logback,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'Logging.class' was compiled against an incompatible version of ch.qos.logback.
[error] one error found

错误一般而且不清楚。事情可能出错的任何想法?

2 个答案:

答案 0 :(得分:0)

在多模块sbt项目中,其中一个模块未正确使用日志记录依赖项。我不得不将依赖项添加到根模块。

答案 1 :(得分:-1)

您错过了添加jar文件。

如果您使用 maven ,请在pom.xml

中添加以下依赖项
<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>1.0.13</version>
</dependency>

如果您使用 gradle ,请将其添加到build.gradle文件中的依赖项部分:

// https://mvnrepository.com/artifact/ch.qos.logback/logback-classic
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.0.13'

资源位置:

Logback configuration