7

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

  }                                                                       
});                                                                         


}

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

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

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

谢谢!

4

1 回答 1

11

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

于 2010-04-16T15:20:20.503 回答