报告在 XML 应用程序上下文中配置的 Spring bean 的错误自动装配。
示例:
public interface FooInterface {...} @Component public class FooBean implements FooInterface {...} @Component public class OtherBean implements FooInterface {...} @Component public class MyComponent { public void setFooInterface(FooInterface foo) {...} }
<beans> <bean class="beans.OtherBean" id="otherBean"/> <bean class="beans.FooBean" id="fooBean"/> <bean autowire="byType" class="beans.MyComponent" id="foo"/> // 报告 "无法自动装配。 有不止一种 'FooInterface' 类型的 bean。 // Beans: otherBean,fooBean. Properties: 'fooInterface' " </beans>