天天看點

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

繼續閱讀