title: The annotation @Configuration is disallowed for this location
body: <p>While following the tutorial on <a href="https://dzone.com/articles/spring-mvc-and-java-based-configuration-1" rel="nofollow noreferrer">dzone</a> to make a simple spring+maven project, i am getting error message @Configuration is disallowed for this location.</p>
  
  <p>My class - </p>
  
  <pre><code>package com.xyz;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.web.servlet.ViewResolver;
  import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
  import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
  import org.springframework.web.servlet.view.InternalResourceViewResolver;
  import org.springframework.web.servlet.view.JstlView;
  @EnableWebMvc
  @ComponentScan(basePackages = "com.example")
  public class SpringConfig extends WebMvcConfigurerAdapter{
  
      @Bean
      public ViewResolver viewResolver() {@Configuration
          InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
          viewResolver.setViewClass(JstlView.class);
          viewResolver.setPrefix("/WEB-INF/pages/");
          viewResolver.setSuffix(".jsp");
          return viewResolver;
      }
      @Override
      public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
          configurer.enable();
      }
  }
  </code></pre>