I moved web.xml to Java annotation configuration
My custom code is
public class WebInitializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext container) {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.setDisplayName("app-name");
context.register(Config.class);
container.addListener(new RequestContextListener());
container.addListener(new ContextLoaderListener(context));
Dynamic dispatcher = container.addServlet("app-name", new DispatcherServlet(context));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/app-name-rest/*");
}
I tried the solution https://stackoverflow.com/a/25210356/6700081 but the line coverage is still 0%