Junit测试出现NoSuchMethodError BridgeMethodResolver.isVisibilityBridgeMethodPair错误

3
我将我的Maven项目升级到了Spring 3.0.7(从3.0.5)。现在,我所有使用JUnit的测试都遇到了问题。
@RunWith(SpringJUnit4ClassRunner.class)

注释失败(出现以下异常),但仅在从Eclipse内部运行时才会出现。我正在运行“Eclipse Indigo Service Release 2”。当我从Linux控制台运行时,所有内容都通过。

有人遇到过这种情况吗?

java.lang.NoSuchMethodError: org.springframework.core.BridgeMethodResolver.isVisibilityBridgeMethodPair(Ljava/lang/reflect/Method;Ljava/lang/reflect/Method;)Z
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.buildAutowiringMetadata(AutowiredAnnotationBeanPostProcessor.java:346)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.findAutowiringMetadata(AutowiredAnnotationBeanPostProcessor.java:317)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(AutowiredAnnotationBeanPostProcessor.java:216)
at  
etc & so forth...
1个回答

2
已解决——问题出在同时引用了3.0.5和3.0.7的JAR包。我从这个问题得到了提示:Error loading Jar file with Tomcat 7, Spring 3 and Camel 2.9.1 虽然Eclipse报告显示所有spring jar文件都是3.0.7,但我发现它仍然保留着对旧版本jar (3.0.5) 的引用。通过删除Maven Repository中所有已有的Spring文件并重建,我找到了这个问题所在。接下来,我开始收到明确的消息,指出缺少 $M2_REPO/com/spring...../3.0.5 jar 文件。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接