2
這是解釋here如何結合java & xml配置完成。有用。測試情境框架具有自3.1.0.M2 Java的配置支持:結合Java&xml彈簧配置進行測試
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
public class LangDetectorTest extends AbstractTestNGSpringContextTests {
@Configuration
static class ContextConfiguration {
@Bean
public LangDetector langDetector() throws SystemException {
LangDetector orderService = new LangDetector();
return orderService;
}
}
}
雖然我不能想出如何把Java配置爲主要配置和負載類似UTIL:性能和東西從XML配置。
我需要做的somwthing這樣的:
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
@ImportResource("classpath:context/LangDetectorTest-test.xml")
public class LangDetectorTest extends AbstractTestNGSpringContextTests {
@Configuration
static class ContextConfiguration {
@Bean
public LangDetector langDetector() throws SystemException {
LangDetector orderService = new LangDetector();
return orderService;
}
}
}
測試情境框架否則Java的配置支持是沒用的,考慮到有隻能通過XML配置來完成噸的東西。
請記住,Spring 3.1尚未完成。里程碑版本功能不完整,所以如果事情似乎缺失,請不要感到驚訝。 – skaffman
@skaffman:那現在它沒有實現,但它很可能在3.1 RC +中? – lisak