I have a bean that I am positive is in the package being scanned by spring (all its siblings work successfully).
@Service
class BeanB {
}
@Service
@DependsOn("BeanB")
class BeanA {
@Autowired
BeanB b;
}
However when I run it I get this:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'BeanB' available
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:682)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1218)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:297)
... 34 more
However BeanB
is present.
When I drill into the spring internals (DefaultListableBeanFactory beanDefinitionMap), it says that it has a bean named beanB
. Why is spring not able to find and wire the correct @AutoWired
(or @Inject
bean, it appears the capitalization is off for the first letter?
I have looked at What is a NoSuchBeanDefinitionException and how do I fix it? but it doesn't seem to deal with the case of "my bean is in there but can't be found from capitalization"