You should be able to do this instead.
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class BeanTest {
@Autowired
private SomeService someService;
@Configuration
@Import(MyContextConfiguration.class)
static class ContextConfiguration {
....
}
}
Also, you don't need to mention AnnotationConfigContextLoader
, Spring by convention will automatically pick up the static inner class annotated with @Configuration
and use the appropriate ContextLoader