我以springboot项目中实现logoutHander的类loginoutHandler为例:
@Autowired
private User userMapper;
@override
public void logout(HttpServletRequest request,HttpServletResponse response,Authentication authentication){
WebApplicationContext applicationContext=Web ApplicationContextUtils.getWebApplicationContext(request.getServletContext());
userMapper=(UserMapper)applicationContext.getBean(“userMapper”);
}