I am trying to inject a auth service to a Filter
-
@Autowired
AuthRequestService authService;
And use it in doFiler
You could use constructor injection. Supposed your filter registration bean lives in a component and has access to the service you could autowire it there and pass it with the constructor
@Autowired
AuthRequestService authRequestService;
[...]
FilterRegistrationBean filterRegBean = new FilterRegistrationBean<>();
filterRegBean.setFilter(new SAPServiceFilter(authRequestService));