In a Spring Boot application I have a class as below:
@Service
public class XYZ{
}
I want to use above in other class ABC like:
public class ABC{
@Autowired
private XYZ xyx;
}
It throws error that XYZ could not be found. I already have @SpringBootApplication in the class where the main method is written. Hence, this will automatically enable @ComponentScan on the package. ABC is created as a bean in spring configuration file. My understanding is, since XYZ has been annoted with @service, spring scans and creates and registers that bean. How can I access that bean in other class without using xml configuration?