AbstractAnnotationConfigDispatcherServletInitializer

391 views Asked by At

I want to know the purpose of below methods inside the class when the class extends AbstractAnnotationConfigDispatcherServletInitializer

  1. protected Class[] getRootConfigClasses() { return new Class[0]; }

    @Override

    1. protected Class[] getServletConfigClasses() { return new Class[] { testAPI.class }; } 3.@Override protected String[] getServletMappings() { return new String[] { "/" }; }
1

There are 1 answers

0
Logemann On

(1) wants a list of @Configuration (user) classes for creating a Root ApplicationContext and (2) wants a list of (user) classes for the AnnotationConfigWebApplicationContext.

So image you have several @Configuration classes coded somewhere, you can register them with:

@Override
protected final Class<?>[] getRootConfigClasses() {
    return new Class[]{CoreConfiguration.class, JpaConfiguration.class,
            ShiroSecurityConfig.class};
}