Issue
I have a project structure that looks like this:
In My Groovy folder contains a class marked with @Component
that I Want to inject in another class inside the java folder. However spring can't find the bean to inject, when I move the class marked with @Component
to the java folder it works fine. How can I make spring aware of the groovy folder?
Solution
You can use @ComponentScan at your Spring application (annotated with @SpringBootApplication) to scan components from other packages.
@ComponentScan(basePackages = "com.stackoverflow.other.package")
See https://www.baeldung.com/spring-component-scanning.
Answered By - Milgo
Answer Checked By - Mildred Charles (JavaFixing Admin)