We have recently migrated to spring boot 1.5.4 from spring MVC, we have moved the dispatcher servlet from web.xml to bean but now we want to remove this explicit dispatcher servlet and want to use an embedded one. When we removed this bean and deploy the app on external tomcat and try to access the APIs we get 404. We have a custom configuration in our application which is also multi-module so we cannot enable @EnableAutoConfiguration. Please help me to remove the servlet dispatcher and enable the embedded one of spring boot. Note: few also have few other servlets like DwrServlet and CXFServlet
Main class
@SpringBootConfiguration
@ComponentScan(lazyInit = true, basePackages = {"com.abc"})
@ImportResource({
"classpath:spring/applicationContext-resources.xml",
"classpath:common-applicationContext-dao.xml",
"classpath:common-applicationContext-service.xml",
"classpath:common-applicationContext.xml",
"classpath:core-applicationContext.xml",
"classpath:spring/applicationContext-validation.xml",
"classpath:spring/security.xml",
"classpath:custom-monitoring-spring.xml"})
@EnableAutoConfiguration
public class WebApplication extends SpringBootServletInitializer {
public WebApplication() {
setRegisterErrorPageFilter(false);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(WebApplication.class);
}
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.setInitParameter("javax.servlet.jsp.jstl.fmt.localizationContext", "ApplicationResources");
servletContext.setInitParameter("javax.servlet.jsp.jstl.fmt.fallbackLocale", "en");
super.onStartup(servletContext);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(WebApplication.class, args);
}
}
Dispatcher Servlet bean which I want to remove
@Bean
public ServletRegistrationBean dispatcherServlet() {
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean();
servletRegistrationBean.setServlet(new DispatcherServlet());
servletRegistrationBean.setName("dispatcher");
servletRegistrationBean.setLoadOnStartup(1);
servletRegistrationBean.addInitParameter("contextAttribute", "org.springframework.web.context.WebApplicationContext.ROOT");
servletRegistrationBean.addUrlMappings("/app/*");
return servletRegistrationBean;
}