1.

What is a Component Scan?

Answer»

When developing Spring Boot applications, tell the Spring Framework where to look for Spring components. A COMPONENT scan is ONE way for Spring to DETECT managed components from Spring. When the APPLICATION starts, Spring needs the information to locate and register all Spring components in the application context. Spring can scan, detect and instantiate components from predefined project packages automatically.

Spring can automatically scan all classes with stereotypes @Component, @Controller, @SERVICE and @Repository

For example

import org.springframework.stereotype.Component; @Component("demoBeanA") public class DemoBeanA { }


Discussion

No Comment Found