Unable To Use ch.qos.logback.classic Classes

2019-07-25 07:07发布

I have spring project setup on Intellij Idea 2016.2 using Maven. For some reason I cannot import or use any class present in ch.qos.logback.classic package. I tried to invalidate cache, re-import maven dependencies.

For example with

import ch.qos.logback.classic.Level;

the IDE says 'cannot resolve symbol Level'. When compiling from command line it says 'package ch.qos.logback.classic does not exist'. Any suggestion what might be wrong?

Update - found the issue. I had set dependency scope to compile. Updating this fixed the issue.

1条回答
一夜七次
2楼-- · 2019-07-25 07:39

Have you added the ch.qos.logback:logback-classic Maven artifact in your dependencies?

You should have something like that in your pom :

<dependencies>
     ...
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.1.3</version>
        </dependency>
     ...
<dependencies>
查看更多
登录 后发表回答