title: java.lang.NoSuchMethodError: org.springframework.beans.factory.annotation.AnnotatedBeanDefinition.setRole(I)V
body: <p>I am facing the following error while trying to run my service. Can someone please help me out in this ? I am not sure if it is a spring version mismatch issue. I use the same version as defined in my <strong>pom.xml</strong>.</p>
  
  <p><strong>Error Trace:</strong></p>
  
  <pre><code>Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
  java.lang.NoSuchMethodError: org.springframework.beans.factory.annotation.AnnotatedBeanDefinition.setRole(I)V
  at org.springframework.context.annotation.AnnotationConfigUtils.processCommonDefinitionAnnotations(AnnotationConfigUtils.java:259)
  at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.registerBeanDefinitionForImportedConfigurationClass(ConfigurationClassBeanDefinitionReader.java:158)
  at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:138)
  at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117)
  at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:327)
  at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232)
  at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275)
  at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95)
  at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:530)
  at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:409)
  at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291)
  at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
  at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4641)
  </code></pre>
  
  <p>Herewith I am sharing my <strong>pom.xml</strong> file</p>
  
  <pre><code> &lt;properties&gt;
  
      &lt;org.springframework.version&gt;5.0.7.RELEASE&lt;/org.springframework.version&gt;
  
      &lt;org.springframework.batch&gt;4.0.1.RELEASE&lt;/org.springframework.batch&gt;
  
    &lt;/properties&gt;
  
    &lt;dependencies&gt;
  
      &lt;!-- Spring dependency--&gt;
  
      &lt;dependency&gt;
  
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
  
        &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
  
        &lt;version&gt;${org.springframework.version}&lt;/version&gt;
  
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
  
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
  
        &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
  
        &lt;version&gt;${org.springframework.version}&lt;/version&gt;
  
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
  
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
  
        &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
  
        &lt;version&gt;${org.springframework.version}&lt;/version&gt;
  
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
  
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
  
        &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
  
        &lt;version&gt;${org.springframework.version}&lt;/version&gt;
  
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
  
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
  
        &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
  
        &lt;version&gt;${org.springframework.version}&lt;/version&gt;
  
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
  
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
  
        &lt;artifactId&gt;spring-expression&lt;/artifactId&gt;
  
        &lt;version&gt;${org.springframework.version}&lt;/version&gt;
  
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
  
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
  
        &lt;artifactId&gt;spring-test&lt;/artifactId&gt;
  
        &lt;version&gt;${org.springframework.version}&lt;/version&gt;
  
        &lt;scope&gt;test&lt;/scope&gt;
  
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
  
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
  
        &lt;artifactId&gt;spring-context-support&lt;/artifactId&gt;
  
        &lt;version&gt;${org.springframework.version}&lt;/version&gt;
  
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
  
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
  
        &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
  
        &lt;version&gt;${org.springframework.version}&lt;/version&gt;
  
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.batch&lt;/groupId&gt;
        &lt;artifactId&gt;spring-batch-core&lt;/artifactId&gt;
        &lt;version&gt;${org.springframework.batch}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- Spring dependency ends--&gt;
        &lt;/dependencies&gt;
  </code></pre>