Cannot deploy Spring App to Websphere

后端 未结 7 1692
傲寒
傲寒 2020-12-31 09:28

I\'ve been developing an application to tomcat during development phase. As we\'re moving forward, my client wants to be deployed to websphere. I\'m attempting to do so on

7条回答
  •  执笔经年
    2020-12-31 10:04

    use @Configuration annotation on the WebAppInitializer class

    @Configuration 
    public class WebAppInitializer implements WebApplicationInitializer {
    
        @Override
        public void onStartup(ServletContext container) {
            // Create the 'root' Spring application context
            AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
            rootContext.register(HibernateConfiguration.class);
    
            // Manage the lifecycle of the root application context
            container.addListener(new ContextLoaderListener(rootContext));
    
            // Create the dispatcher servlet's Spring application context
            AnnotationConfigWebApplicationContext dispatcherServlet = new AnnotationConfigWebApplicationContext();
            dispatcherServlet.register(SpringWebConfig.class);
    
            // Register and map the dispatcher servlet
            ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(dispatcherServlet));
            dispatcher.setLoadOnStartup(1);
            dispatcher.addMapping("/");
    
        }
    
     }
    

提交回复
热议问题