Eclipse cannot find logback-test.xml on my classpath for unit tests

I'm struggling with Eclipse recognizing my logging configuration when I quickly run tests from Eclipse (Alt + Shift + X, T) or run from Run Configurations. I really don’t care that I can’t log in from the tests themselves, but I really just provide the configuration so that any log statements that are executed are not interrupted.

Failed to instantiate [ch.qos.logback.classic.LoggerContext] Reported exception: java.lang.NoSuchMethodError: ch.qos.logback.core.util.Loader.getResourceOccurrenceCount(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/util/Set; at ch.qos.logback.classic.util.ContextInitializer.multiplicityWarning(ContextInitializer.java:160) at ch.qos.logback.classic.util.ContextInitializer.statusOnResourceSearch(ContextInitializer.java:183) at ch.qos.logback.classic.util.ContextInitializer.getResource(ContextInitializer.java:141) at ch.qos.logback.classic.util.ContextInitializer.findURLOfDefaultConfigurationFile(ContextInitializer.java:130) at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148) at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85) at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55) at org.slf4j.LoggerFactory.bind(LoggerFactory.java:144) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:123) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:337) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:287) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:309) 

I have logback-test.xml in src / test / resources and configured this as the source folder with the output of the target / test classes.

enter image description hereenter image description here

I even tried to edit the Classpath for Run JUnit for my project and added the test classes folder there, and that didn't help.

enter image description here

Is there something simple I'm missing? I do not seem to remember that this problem was in the past with other projects.

+5
source share
1 answer

I checked my pom.xml, and logback-classic did not have the specified version, and logback-core did. I set the property for the version and set them to be the same.

+11
source

Source: https://habr.com/ru/post/1211734/


All Articles