Could not resolve matching constructor (hint: specify index/type/name arguments for simple paramet
对象的属性类型与applicationContext.xml配置文件ioc的属性类型不一致
<constructor-arg value="teacher"/>
package org.lanqiao.entity;
public class Course {
private String courseName;
private int courseHour;
private Teacher teacher;
public Course() {
}
public Course(String courseName, int courseHour, Teacher teacher) {
this.courseName = courseName;
this.courseHour = courseHour;
this.teacher = teacher;
}
public String getCourseName() {
return courseName;
}
public void setCourseName(String courseName) {
this.courseName = courseName;
}
public int getCourseHour() {
return courseHour;
}
public void setCourseHour(int courseHour) {
this.courseHour = courseHour;
}
public Teacher getTeacher() {
return teacher;
}
public void setTeacher(Teacher teacher) {
this.teacher = teacher;
}
public void showInfo(){
System.out.println(this.courseName+","+
this.courseHour+","+this.teacher);
}
}
正确写法:<constructor-arg ref="teacher"/>
总结:value:8个基本类型+String
ref: 普通的对象类型