【发布时间】:2013-10-18 08:21:21
【问题描述】:
我有以下 java 类:
@ContextConfiguration(locations = { "classpath:/pathToXml" })
public class AbstractServiceTest extends AbstractTransactionalJUnit4SpringContextTests {
@Autowired
protected SessionFactory sessionFactory;
@Autowired
protected MyBean myBean;
public Integer doSomething(){
return myBean.returnVeryImportantInteger();
}
...
}
如果我写new AbstractServiceTest ()
sessionFactory 为空。(在 pathToXml 中写入的 sessionFacory 信息)
我怎么能说 spring 它看到了来自"classpath:/pathToXml" 的配置?
@ContextConfiguration(locations = { "classpath:/anotherPathToXml" })
public class MyClass
public void myMethod(){
// I want to use here method doSomething from AbstractServiceTest class
}
}
【问题讨论】:
标签: java spring spring-mvc configuration