天天看点

Spring 配置文件报错:Bean property 'xxx' is not writable or has an invalid setter method

错误原因:在生成属性的get set 方法时,eclipse默认为protected,由于跨包导致spring配置文件不能获取到set方法,因此注入失败!浪费一小时找bug

错误代码:

protected void getTid() {
		return tid;
	}	

	protected void setTid(int tid) {
		this.tid = tid;
	}
	protected String getTname() {
		return tname;
	}
	protected void setTname(String tname) {
		this.tname = tname;
	}
}
           

将protected 更改为public即解决问题

bug

继续阅读