找了很多办法,无论是加@Component还是编写工具类实现ApplicationContextAware,始终为null。
最后使用这两行代码解决:
WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
DailySurveyService service = (DailySurveyService) context.getBean("dailySurveyService");
找了很多办法,无论是加@Component还是编写工具类实现ApplicationContextAware,始终为null。
最后使用这两行代码解决:
WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
DailySurveyService service = (DailySurveyService) context.getBean("dailySurveyService");