I am writing some JUnits for a Spring application, the Spring version used for which is
<spring.version>3.2.8.RELEASE</spring.version>
the dependencies are defined as
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
then in my JUnit
test i am using the annotations as
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="classpath:config/test-application-context-datasource.xml")
When i am trying to execute the test case it fails to initialize, ie it doesn't even goes into the @Before
method and throws below exception:
java.lang.NoClassDefFoundError: org/springframework/core/type/AnnotatedTypeMetadata
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:118)
AnnotatedTypeMetadata is only available after spring release 4.10.0 i believe, but since i am not using that anywhere in my application and the version of my spring-test and spring-core is same, why is this even getting referred.
Any thoughts?
You obviously have incompatible versions of various Spring JARs on your classpath.
To figure out which incompatible versions (ie, other than 3.2.8.RELEASE
) are present in your classpath, execute mvn dependency:tree
in your project's folder.
Then ensure that you avoid having the incompatible versions on your classpath -- for example, by adding exclusions to your Maven POM for any dependencies that are pulling in the unwanted versions as transitive dependencies.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.