Spring Autowire NoSuchBeanDefinitionException

When Autowiring Spring Beans, a common error is to see a NoSuchBeanDefinitionException.

Here is an example of the NoSuchBeanDefinitionException you may see thrown by the Spring context:

NoSuchBeanDefinitionException

By default, Spring will Autowire beans by type. You can see in the error message the type of bean Spring is expecting to find. The problem is that the Spring Context is not finding a Java class of this type configured for use. There are a couple small gotch ya’s when using the Spring Boot application and in how Spring Boot scans for eligible Spring Beans.

Free Introduction to Spring Tutorial

Are you new to the Spring Framework? Checkout my Free Introduction to Spring Online Tutorial.

In the video below, I show you how to correct a component scan problem in Spring Boot causing a NoSuchBeanException.

Share

Leave a Reply