08-02-2023, 03:47 PM
By default, in Spring boot applications, component scan is done inside the package where your main class resides. any bean which is outside the package will not the created and thus gives the above mentioned exception.
Solution: you could either move the beans to the main spring boot class(which is not a good approach) or create a seperate configutation file and import it:
@Import({CustomConfigutation1.class, CustomConfiguration2.class})
@SpringBootpplication
public class BirthdayApplication {
public static void main(String [] args) {
springApplication.run(BirthdayApplication.class, args );
}
}
Add beans to these CustomConfiguration files.
Solution: you could either move the beans to the main spring boot class(which is not a good approach) or create a seperate configutation file and import it:
@Import({CustomConfigutation1.class, CustomConfiguration2.class})
@SpringBootpplication
public class BirthdayApplication {
public static void main(String [] args) {
springApplication.run(BirthdayApplication.class, args );
}
}
Add beans to these CustomConfiguration files.