Spring MutableValues的NoSuchMethodError

jak*_*kob 7 java testng spring nosuchmethoderror

我编写了一个测试,其中我用注释指定了我的应用程序上下文位置.然后我将我的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());                                

  }                                                                       
});                                                                         


}
Run Code Online (Sandbox Code Playgroud)

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

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

我不知道从哪里开始寻找,为什么我会收到此错误,我该如何解决?Info springframework 3.0.2.RELEASE,Hibernate 3.4.0.GA,testng 5.9

谢谢!

axt*_*avt 11

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