@SpringBootApplication marks a Spring Boot application entry point and enables classpath scanning, component discovery, and automatic configuration. Discovered classes become Spring beans in the application context. section 1.3
Use its default behavior carefully when configuring focused test applications:
- Component scanning may discover dependencies such as external-service implementations that tests should replace. section 1.3
- Replacing one discovered bean can require custom configuration, selective scanning, auto-configuration, exclusions, properties, and a stub bean. section 1.3
- A focused test configuration can therefore be preferable when the full application context is inappropriate. section 1.3
Replacing a discovered service
An application that stores Widgets may discover WidgetValidator through @SpringBootApplication. A test that must avoid network calls can exclude that implementation and provide a StubWidgetValidator through custom configuration instead. section 1.3
Figure 1.3 The architecture of the application we would like to test. Arrows represent the data flowing through the system. The WidgetValidator cannot be used in tests, and needs to be replaced by a stub.
Shows the application dependency graph and why an externally accessed validator may need replacement during testing. section 1.3

