启动Spring Boot项目时,报错:
LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.LogFactoryImpl loaded from file:/Users/hao/.m2/repository/com/fireflysource/firefly-slf4j/4.9.5/firefly-slf4j-4.9.5.jar). If you are using WebLogic you will need to add ‘org.slf4j’ to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.impl.LogFactoryImpl
IDEA插件中安装Maven Helper,点击pom.xml,会有一个Dependency Analyzer选项,在里面点击All Dependencies as List,搜索上面错误里的firefly-slf4j,然后在左侧栏里点击firefly-slf4j,右侧栏里点击最上面的节点,右键Exclude,然后刷新maven,重新启动就可以了。
又坑了我半天,如果是Java 9及以上,用module-info更容易解决,可以当前是Java 8,必须在maven这里解决。