Spring MutableValues 的 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());
}
});
}
当我运行测试时,我收到一个异常,指出无法加载应用程序上下文,它归结为:
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
谢谢!
I have written a test where i specify my application context location with annotations.
I then autowire my dao into the test.
@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
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此方法是在 Spring 3.0 中添加的,因此您可能在类路径中的某个位置有 3.0 之前的 Spring 版本。检查你的类路径。
This method was added in Spring 3.0, so you probably have a pre-3.0 Spring version somewhere in classpath. Check your classpath.