I am getting this error
org.springframework.beans.factory.BeanCreationException:
Could not autowire method:
This is my spring’s xml configuration.
<bean ...>
...
<property name="InfoModel" ref="InfoModel"></property>
</bean>
Here is my code where I am autowiring this in Java class
private InfoModel infoModel;
@Autowired
public void setInfoModel(InfoModel infoModel) {
this.infoModel= infoModel;
}
Am I missing something. I suspect that I should make an Interface of InfoModel in order to make it autowire?
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.model.InfoModel] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:920)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:789)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:547)
if you do
@Autowiredyou don’t need to mark it as property in xml. just declare InfoModel as bean in XML and removepropertyfrom xml for you bean where you have injectedInfoModelSumming up
1 You need a bean definition in your XML for
InfoModel2 You need to remove
propertyfrom XML3 Make sure you have made your context annotation driven by adding