bestlong 怕失憶論壇
標題:
Class is mapped, but is not included in any persistence unit
[打印本頁]
作者:
bestlong
時間:
2013-5-8 10:12
標題:
Class is mapped, but is not included in any persistence unit
在 Eclipse Indigo 從 git 匯入專案
因為 git 源碼中沒有 .project 與 .classpath 所以 eclipse 無法直接識別建立
只好自行處理繁瑣的重組過程
處理到可以運行 WebApp 且 Unit test 都過關的狀況下
卻還是有下列錯誤訊息
Class "domain.Member" is mapped, but is not included in any persistence unit Member.java /springmvc/src/main/java/domain line 21 JPA Problem
此專案的源碼基礎是用 Jboss Tools 建立 Spring MVC Project 後修改而來的
作者:
bestlong
時間:
2013-5-8 10:39
錯誤訊息是 Eclipse 所識別出來的
Member.java 程式碼片段如下:
package domain;
//省略 import...
@Entity
@Table(uniqueConstraints = @UniqueConstraint(columnNames = "email"))
public class Member implements Serializable
{
//省略
}
複製代碼
因為專案是硬組出來的所以專案設定應該有所差異
打開專案設定進入 JPA 的項目,畫面如下圖:
2013-5-8 10:23 上傳
下載附件
(103.25 KB)
紅色框就是問題原因
被設定成較為麻煩的模式,需要將所有 Entity class 列表設定在 persistence.xml 內
因為沒有設定所以當 Member class 加了 @Entity 就會出現警告
所以改成自動探索的設定之後就解決了錯誤訊息
圖片附件:
JPA Problem.png
(2013-5-8 10:23, 103.25 KB) / 下載次數 283
http://www.bestlong.idv.tw/forum.php?mod=attachment&aid=MzY4fDJmYTRkMGJhfDE3NTAwNzUyMTN8MA%3D%3D
歡迎光臨 bestlong 怕失憶論壇 (http://www.bestlong.idv.tw/)
Powered by Discuz! X1.5