我编写了一个测试,在其中使用注释指定应用程序上下文位置。
然后我将我的 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());
}
});
}
当我运行测试时,我收到一个异常,表明无法加载应用程序上下文,它可以归结为:
Caused by: 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 版本。检查你的类路径。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)