我试图诠释了一套方法如下:@Autowired任何方法名称与任意数量的参数
package com.spring.examples;
public class MyBean
{
private String name;
private int age;
@Autowired
public void set(String name, int age)
{
this.name = name;
this.age = age;
}
}
配置文件:
<bean id="myBean" class="com.spring.examples.MyBean">
<property name="name" value="Marie" />
<property name="age" value="101" />
</bean>
我得到这个错误:
No qualifying bean of type [java.lang.String] found for dependency: expected at least 1 bean which qualifies
如何配置此bean以正确调用set
方法?
对于这两个变量,您应该有两个不同的setters和getters。 – Jacopofar