不用依赖ServletContext
// 取得WebApplicationContext
WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext();
// 取出Bean
webApplicationContext.getBean("xxx",xxx.class) ;
// 取出ServletContext
ServletContext servletContext = webApplicationContext.getServletContext();