V4.5 集成 Springboot 异常
@Configuration
public class WebConfig {
/**
\* 统计报表servlet注册
*
*/ @Bean
public ServletRegistrationBean<ReportServlet\> servletRegistrationBean() {
ServletRegistrationBean<ReportServlet\> registration = new ServletRegistrationBean<>(new ReportServlet());
registration.setLoadOnStartup(1);
registration.addInitParameter("configFile", "/WEB-INF/reportConfig.xml");
registration.addInitParameter("headless", "none");
registration.setName("reportServlet");
registration.addUrlMappings("/reportServlet");
ServletMappings.mappings.put("com.runqian.report4.view.ReportServlet", "/reportServlet");
System.out.println("润乾servlet注册完成");
return registration;
}
@Bean
public ServletRegistrationBean<DMServlet\> servletRegistrationBean1() {
ServletRegistrationBean<DMServlet\> reg = new ServletRegistrationBean<>(new DMServlet());
reg.setLoadOnStartup(2);
reg.addInitParameter("configFile", "/WEB-INF/dmConfig.xml");
reg.setName("DMServlet");
reg.addUrlMappings("/DMServlet","/DMServletAjax");
ServletMappings.mappings.put("com.raq.web.view.DMServlet", "/DMServlet");
return reg;
}
运行异常
org.jdom.JDOMException: Error in building
Servlet.init()for servlet [DMServlet] threw exception
java.lang.NullPointerException: null
看下去掉 dmservlet 后是否还有错误,dmservlet 不是必须的可以先去掉。
如果还有错误,看下是否是 jdom 版本问题,pom 里引入润乾自带的那个 jdom 试下
使用润乾自带的 jdom 的还是报错
需要引入 web.xml