Easy java spring

Component removed from a class another bean Autowires?

The 30 second answer

Component scanning no longer registers that class, so the dependent bean cannot be created and startup fails with UnsatisfiedDependencyException or NoSuchBeanDefinitionException. Spring Boot's failure analyzer usually says a bean of that type could not be found. It still works if you declare the bean with a Bean method, or if the injection is optional through required false, Optional, or ObjectProvider.

Component scanning no longer registers it, so the dependent bean can't be created: startup fails with UnsatisfiedDependencyException / NoSuchBeanDefinitionException ("required a bean of type … that could not be found" in the Spring Boot failure analyzer). Exceptions: it still works if the bean is declared via an @Bean method, or the injection is optional (@Autowired(required = false), Optional<T>, ObjectProvider<T>).

Sources:

Sources (0)
See inline citations in the answer above.