I use Java configuration for my Spring MVC based webapp. I have implemented the WebApplicationInitializer interface of Spring framework.
public class MyInitializer implements WebApplicationInitializer {
...
@Override
public void onStartup(final ServletContext servletContext) throws ServletException {
//all the code for setting context
}
...
}
Now, I want to create a Main class as another entry point (for testing and other purposes) where I would like to Autowire
my beans. For setting context I would like to use the same method here (this would prevent recopying the code). How can I do this ?