BAEL-3283 - Refactored the code as per review comments.
This commit is contained in:
@@ -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("/");
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user