Skip to main content

DI in Spring

Ayman Patel

Ayman Patel

Back End Engineer @ Mastercard

@Import is to add a configuration class into another configuration class.

http://docs.spring.io/spring-javaconfig/docs/1.0.0.M4/reference/html/ch04s03.html

@ComponentScan is to scan for components declared in your code, like @Service, @Component, @Repository, among others.

http://docs.spring.io/spring-javaconfig/docs/1.0.0.M4/reference/html/ch06s02.html

I think you need to add in your configuration class the @ComponentScan so it can scan the package with your component classes.

https://stackoverflow.com/a/33660489/9642851