0

"No view resolvers found" with annotation based config

I am using @Configuration classes instead of the traditional dispatcher-servlet.xml to configure a SpringMVC 3.2 application. In my @Configuration class I configure a view resolver like so

@Configuration
@EnableWebMvc
@ComponentScan("com.austinbv.usethisroom")
public class DispatcherModule {
  @Bean
  public InternalResourceViewResolver internalResourceViewResolver() {
    InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    resolver.setPrefix("/WEB-INF/pages/");
    resolver.setSuffix(".jsp");
    return resolver;
  }
}


and then I register the @Configuration class with my WebApplicationInitializer

@SuppressWarnings("unused")
public class WebAppInitializer implements WebApplicationInitializer {
  @Override
  public void onStartup(ServletContext container) {
    AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext();
    dispatcherContext.register(DispatcherModule.class);


    ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(dispatcherContext));
    dispatcher.setLoadOnStartup(1);
    dispatcher.addMapping("/");
  }
}

Even though a view resolver is registered I still get the warning. Is there a way to either suppress the warning like I have done with the unused waring on my WebAppInitializer, or can I set Intellj to understand the view resolver.

Thank you
Austin

1 comment

Please sign in to leave a comment.