I wrote a simple set of classes to show a friend about using Annotations for AOP (instead of xml config) . We couldnt get the @ComponentScan to work AND AnnotationConfigAppl
Usually you should use @ComponentScan
along with a @Configuration
annotated class and keep in mind that @ComponentScan without arguments tells Spring to scan the current package and all of its sub-packages..
The @Component class tells Spring to create a bean of that type so you no longer need to use xml configuration, and the bean is a class that can be instantiated => no interface / abstract classes. So, in your case, you should remove the @Component from PersonOperationsI
and leave it only in PersonOperations
. When you annotate a class with @Component, the default name given to the bean is the class name with lower first letter, so you should call ctx.getBean("personOperationsI")
or ctx.getBean(PersonOperations.class)
And for the future read these naming conventions for interfaces and implementations. In your case I would modify the following :
PersonOperationsI
to Operations