Video in progress
When you see "No qualifying bean of type ... available", what do you check?
Spring couldn't find a bean of that type. Usually the annotation is missing, the class isn't covered by component scan, a conditional bean (@Profile, @ConditionalOn...) wasn't created, or the type is wrong.
📖 Answer
I usually go through it in this order:
- Is there an annotation? Without
@Service/@Componentor a@Beanmethod, Spring doesn't know about the class. - Package. If the
@SpringBootApplicationclass is inuz.shop.appand the service is inuz.shop.billing, it won't be scanned. Move the main class to a higher-level package. - Conditions. The bean has
@Profile("prod")and you're running indev. Or a@ConditionalOnPropertyisn't satisfied. - Type. You're asking for the implementation class, but the bean is a JDK proxy — it's only visible through the interface.
- Module. In a multi-module project the required module isn't added as a dependency.
Read the "Consider defining a bean..." part at the bottom of the error message. Also, if you start with --debug, you get the Conditions Evaluation Report — it tells you which auto-config didn't kick in and why.
Sign up to mark studied questions and save your progress.