spring 建立物件的異常

2021-10-08 06:43:15 字數 704 閱讀 9119

---恢復內容開始---

今天使用spring框架建立物件,遇到如下異常:

servlet.service() for servlet [jsp] in context with path threw exception

[org.springframework.beans.factory.nosuchbeandefinitionexception:

no unique bean of type [com.gede.dao.unit.schooltyperl***ao] is defined:

expected single bean but found 0: ] with root cause

org.springframework.beans.factory.nosuchbeandefinitionexception:

no unique bean of type [com.gede.dao.unit.schooltyperl***ao] is defined:

expected single bean but found 0:   

總結來說,就是沒有這個實體類 的物件,即建立失敗

解決辦法:

(1)注意  注意  注意 :

要 明白 建立物件的方式:

spring 兩種建立物件的方式:

a、用註解的方式

b、用 配置檔案xml 檔案 寫 bean 的 方式

Spring 使用Spring建立物件

xmlversion 1.0 encoding utf 8 beans xmlns xmlns xsi xmlns p xsi schemalocation spring beans 4.1.xsd beans 2.編寫domain,dao,service 3.在spring中註冊元件 要sprin...

Spring 研究spring建立物件的方式

一共三種方式 1 呼叫預設建構函式。2 利用靜態工廠方法建立。3 利用例項工廠方法建立 呼叫預設建構函式建立物件 在 cn.google.spring.createobject.method public class helloworld public void hello public class...

spring學習2 spring建立物件的方式

pojo類 public class user2 public void setname string name override public string tostring xml 測試類 test public void test2 結果,可以發現,呼叫了無參構造方法 user2 的無參建構函...