本文主要是介绍Bean named 'BService' is expected to be of type 'path1' but was actually of type 'path2',希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
报错:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'AService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'BService' is expected to be of type 'path1' but was actually of type 'path2'
……
原因是,AService里面用@Resource调用了Bsource,而Bsource在路径1和路径2中均存在。
解决方法是在@Resource注解里加上(name = "xxx"),其中xxx为Bsource的@Service("xxx")名字。这样做可以指定唯一路径,就不会报这个错了。
这篇关于Bean named 'BService' is expected to be of type 'path1' but was actually of type 'path2'的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!