BAEL-3283 - Refactored the code as per review comments.

This commit is contained in:
sandip singh
2019-11-18 19:36:11 +05:30
parent 988655875b
commit fea1b6bf8a
20 changed files with 4 additions and 3 deletions

View File

@@ -0,0 +1,28 @@
package com.baeldung.config;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
public class WebInitializer implements WebApplicationInitializer {
@Override
public void onStartup(javax.servlet.ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.register(DataSourceConfig.class);
context.register(ThemeMVCConfig.class);
servletContext.addListener(new ContextLoaderListener(context));
servletContext.setInitParameter("spring.profiles.active", "database");
ServletRegistration.Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(context));
servlet.setLoadOnStartup(1);
servlet.addMapping("/");
}
}