錯誤堆疊關鍵行
Caused by: java.io.FileNotFoundException: class path resource [serviceImpl/serviceimpl.class] cannot be opened because it does not exist
原因分析
applicationContext.xml 中定義:
<bean id="serviceSvc" name="service" class="serviceImpl.serviceimpl"/>
- Spring 嘗試載入
serviceImpl.serviceimpl 類別,但 classpath 下找不到對應的 .class 檔案。
- 常見原因:
- 類別名稱拼寫錯誤(大小寫、包名)。
- 專案未正確編譯,
target/classes 或 WEB-INF/classes 缺少該類別。
- Maven 打包未包含該模組,或
component-scan 基礎包路徑設定錯誤。
排查步驟
- 確認
serviceImpl.serviceimpl 類別實際存在且已編譯。
- 檢查
applicationContext.xml 的 class 屬性是否為完整類別名(含包名),例如 com.example.serviceImpl.ServiceImpl。
- 清理專案:
mvn clean compile 或 IDE 執行 Clean/Rebuild。
- 若為多模組專案,確認依賴模組已安裝至本地倉庫。