I have a spring boot application. Packaged as a war file, such that the contents are as follows
staticorg - springframework - boot -loader - SpringClassesMETA-INF - MANIFEST.MF - maven -my.group.id - my-artifact-id - pom.xml & pom.propertiesWEB-INF - lib (contains all jars) - classes (my main application's classes) - some other stuff - web.xml - main-servlet.xml
Where web.xml and main-servlet.xml are the configuration xml's
I tried, from the springBoot application doing as follows:
@EnableWebMvc@EnableAutoConfiguration@Configuration@ImportResource({ "classpath:main-servlet.xml"})public class FakeAppBooter { public static void main(String args[]) { SpringApplication.run(FakeAppBooter.class, args); System.out.println("Test"); } public DispatcherServlet mvcDispatcherServlet() { XmlWebApplicationContext ctx = new XmlWebApplicationContext(); ctx.setConfigLocation("classpath:main-servlet.xml"); DispatcherServlet dispatcherServlet = new DispatcherServlet(ctx); return dispatcherServlet; } @Bean public ServletRegistrationBean mvcServletRegistrationBean() { ServletRegistrationBean bean = new ServletRegistrationBean(); bean.setServlet(mvcDispatcherServlet()); ArrayList<String> list = new ArrayList<>(); list.add("/"); bean.setUrlMappings(list); return bean; }}
However on startup I get :
Caused by: java.io.FileNotFoundException: class path resource [main-servlet.xml] cannot be opened because it does not exist at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:329) ... 25 more
I need these to define the servlets for my application.
what should I do?