当前位置:   article > 正文

java 显示 装配_java – 无法自动装配方法

could not autowire method

我收到了这个错误

org.springframework.beans.factory.BeanCreationException:

Could not autowire method:

这是我的spring的xml配置.

...

这是我的代码,我在Java类中自动装配它

private InfoModel infoModel;

@Autowired

public void setInfoModel(InfoModel infoModel) {

this.infoModel= infoModel;

}

我错过了什么.我怀疑我应该创建一个InfoModel接口才能使其自动装配?

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)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/946607
推荐阅读
相关标签
  

闽ICP备14008679号