我编写了一个测试,在其中指定带有注释的应用程序上下文位置。然后,我将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
谢谢!
该方法是在Spring 3.0中添加的,因此您可能在类路径中的某处安装了3.0之前的Spring版本。检查您的类路径。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句