【发布时间】:2019-11-21 07:51:45
【问题描述】:
我将 web.xml 移动到 Java 注释配置中
我的自定义代码是
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/*");
}
我试过https://stackoverflow.com/a/25210356/6700081的解决方案,但是线路覆盖率还是0%
【问题讨论】:
-
抱歉,您的问题是什么?
-
我想知道是否可以对此进行单元测试
标签: spring-boot spring-mvc spring-test