アプリケーションコンテキストの場所をアノテーションで指定するテストを作成しました。次に、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;
どこから探し始めるのかわかりません。なぜこのエラーが発生するのですか、どうすれば解決できますか?情報springframework3.0.2.RELEASE、Hibernate 3.4.0.GA、testng 5.9
ありがとうございました!