java 带有 Spring MutableValues 的 NoSuchMethodError

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2653958/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 22:13:58  来源:igfitidea点击:

NoSuchMethodError with Spring MutableValues

javaspringtestngnosuchmethoderror

提问by jakob

I have written a test where i specify my application context location with annotations. I then autowire my dao into the test.

我已经编写了一个测试,其中我用注释指定了我的应用程序上下文位置。然后我将我的 dao 自动连接到测试中。

@ContextConfiguration(locations = {"file:service/src/main/webapp/WEB-INF/applicationContext.xml"}) 
public class MyTest extends AbstractTestNGSpringContextTests {

@Autowired                                      
protected MyDao myDao;                        

private PlatformTransactionManager transactionManager;
private TransactionTemplate transactionTemplate;      


@Test                                   
public void shouldSaveEntityToDb() { 
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {        
    protected void doInTransactionWithoutResult(TransactionStatus status) { 

    Entity entity = new Entity();

    //test
    myDao.save(entity)

    //assert                                                            
    assertNotNull(entity.getId());                                

  }                                                                       
});                                                                         


}

When i run the test i get an exception which states that the application context could not be loaded and it boils down to:

当我运行测试时,我收到一个异常,指出无法加载应用程序上下文,它归结为:

    Caused by: java.lang.NoSuchMethodError:
    org.springframework.beans.MutablePropertyValues.add(Ljava/lang/String;Ljava/lang/Object;)Lorg/springframework/beans/MutablePropertyValues;

I have no idea where to start looking, why do i get this error and how can i resolve it? Info springframework 3.0.2.RELEASE, Hibernate 3.4.0.GA, testng 5.9

我不知道从哪里开始寻找,为什么会出现此错误以及如何解决?信息 springframework 3.0.2.RELEASE、Hibernate 3.4.0.GA、testng 5.9

Thank you!

谢谢!

回答by axtavt

This method was added in Spring 3.0, so you probably have a pre-3.0 Spring version somewhere in classpath. Check your classpath.

这个方法是在 Spring 3.0 中添加的,所以你可能在类路径中的某个地方有一个 3.0 之前的 Spring 版本。检查您的类路径。