1. 程式人生 > >applicationContext.xml-bean屬性錯誤寫法

applicationContext.xml-bean屬性錯誤寫法

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:  普通的物件型別