Can SpringBeanAutowiringInterceptor be removed from the code if we create the bean manually and inject it?

87 Views Asked by At

I am trying to upgrade spring from 4 to 5 in one of our project due to security reasons. In one class, we are using SpringBeanAutowiringInterceptor as an interceptor. I went through the documentation, where they have mentioned it is used to inject bean which are annotated with @Autowired. So, if it is used for autowiring, can I remove the said interceptor altogether and inject the bean with @Inject annotation (of course after creating the required beans). Is there any difference between directly injecting the bean and Interceptor injecting it for you?

Original Code snipped:

@Interceptors(SpringBeanAutowiringInterceptor.class)

public class foo(){

@Autowired
SomeBean bean;
}

I have removed the interceptor and changed the code to:

public class foo(){

@Inject
SomeBean bean;
}

I did some sanity around these flows and they are working perfectly fine with these changes. So not sure if it will impact in any other way.

0

There are 0 best solutions below