2017-03-05 34 views
0

我有一个黄瓜测试,当我尝试获取一个bean时,会抛出一个非法访问错误。我一直无法弄清楚为什么这不好。Cucumber中的弹簧错误java.lang.IllegalAccessError:试图访问类

@Given('^test$') 
public void myTest(){ 
    ApplicationContext ctx = new AnnotationConfigApplicationContext(AppInjector.class); 
    MyBean bean = ctx.getBean(MyBean.class) 
} 

java.lang.IllegalAccessError: tried to access class MyBean from StepDef 

回答

0

的解决方案是

@ContextConfiguration(classes = AppInjector.class) 

添加到类的顶部,然后用@Inject在依赖拉。