Searching beans using component scanning

The following minimum configuration is required to search beans using component scanning in a Spring application:

    package com.packt.patterninspring.chapter4.bankapp.config; 
 
    import org.springframework.context.annotation.ComponentScan; 
    import org.springframework.context.annotation.Configuration; 
 
    @Configuration 
    @ComponentScan 
    public class AppConfig { 
    
    } 

The AppConfig class defines a Spring wiring configuration class same as the Java-based Spring configuration in the previous section. There is one thing to be observed here--the AppConfig file has one more @ComponentScan, as earlier it had only the @Configuration annotation. The configuration file AppConfig is annotated with @ComponentScan to enable component ...

Get Spring 5 Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.