使注解@ContextConfiguration同时支持locations和classes
@Configuration @ImportResource("classpath:META-INF/dataContext.xml") class TestConfig { }
And, in your test code use the following:
@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {Configuration.class, TestConfig.class}) @ActiveProfiles("test") public class CityDaoImplTest { ... }