The solution to this <indexentry content="annotation-based DI:Java class, defining as with annotation">problem is to define <context:component-scan> in an application context (XML) file. When Spring reads this element, it will start scanning the beans from the Java package defined by its attribute, base-package. You can instruct Spring to treat the Java class as <bean> by declaring class-level annotation @Component. In short, defining annotation-based configuration is a two-step process, as follows:
- Scanning the package: This can be done by reading the base-package attribute of <context:component-scan>. Spring will start scanning for the classes in that Java package.
- Defining beans: Out of ...