title: importing XML config into java config based (annotation) project
body: <p>I'm working on Spring MVC annotation based application. I have web.xml file entry as follows (using WebConfig.java for configuration):</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;sdsdispatcher&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;contextClass&lt;/param-name&gt;
          &lt;param-value&gt;org.springframework.web.context.support.AnnotationConfigWebApplicationContext&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;com.conf.WebConfig&lt;/param-value&gt;
      &lt;/init-param&gt;            
  
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  </code></pre>
  
  <p>Now when I try to integrate security related XML file I'm facing following error</p>
  
  <blockquote>
    <p>org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:638)</p>
  </blockquote>
  
  <p>I tried to import xml file as follows:</p>
  
  <pre><code>@Configuration
  @EnableWebMvc
  @ComponentScan("com.stk.controller")
  @ImportResource({"securityContext.xml"})
  public class WebConfig extends WebMvcConfigurerAdapter {
  </code></pre>
  
  <p>Screenshot</p>
  
  <p><a href="https://i.stack.imgur.com/BosWG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BosWG.jpg" alt="enter image description here"></a>
      <a href="https://i.stack.imgur.com/BosWG.jpg" rel="nofollow noreferrer">http://i.stack.imgur.com/BosWG.jpg</a></p>