在写测试用例的时候,如果是springboot的应该加上 springboot的标签:
@SpringBootTest(classes = ApplicationLoader.class)
@ActiveProfiles("dev")
@RunWith(SpringJUnit4ClassRunner.class)

 

调用某个Listener的两个方法:
一、
SpringUtil.getBean(AppealDetourListener.class);
就是:
(1)applicationContext.getBean(AppealDetourListener.class);
(2)applicationContext.getBean("detourDataListener");
都可以
但是不能用下面的,因为这是springMVC的标签:
(AppealDetourListener) ContextLoader.getCurrentWebApplicationContext().getBean("detourDataListener");

二、用自动注入的方式也可以;

 @Autowired
    private AppealDetourListener appealDetourListener;

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-07
  • 2021-09-05
猜你喜欢
  • 2022-12-23
  • 2021-12-23
  • 2021-09-20
  • 2021-06-23
  • 2022-01-15
  • 2022-12-23
  • 2021-12-08
相关资源
相似解决方案