我試圖創建一個使用Spring TestContext框架加載applicationContext.xml的測試,代碼很簡單:了Spring TestContext框架
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"/applicationContext.xml"})
public class ApplicationContextLoadingTest {
@Autowired
private ApplicationContext applicationContext;
@Ignore
@Test
public void testContext() {
}
}
當我運行測試我得到了錯誤信息:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pollInitializer' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) ...
任何人都知道這意味着什麼?由於
我自動連線ApplicationContext的原因是我想測試該文件可以成功加載。 – ohana 2011-03-31 20:27:16