I use Maven, Java 10, Spring boot 2 and Junit 5 for create my application with unit tests.
Main application class:
package mypackage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MyApplication {
private final static Logger LOGGER = LoggerFactory.getLogger(MyApplication.class);
public static void main(String[] args) {
LOGGER.info("I'am running...");
SpringApplication.run(MyApplication.class, args);
}
}
My JUnit test class:
package mypackage;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes=MyTest.class)
public class MyTest {
private static final Logger LOGGER = LoggerFactory.getLogger(MyTest.class);
@Test
public void myTest() {
LOGGER.info("Message from test");
}
}
When i import my maven project in Eclipse 4.10, i get error on my test class:
The package org.slf4j is accessible from more than one module: <unnamed>, slf4j.api
But mvn install work fine and maven-surefire-plugin run correct. What i'm doing wrong? Or it's eclipse bug? Maybe Java 10, Junit and SLF4J not working together? in my module-info.java: requires slf4j.api;
Please help me.