bestlong 怕失憶論壇's Archiver

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 程式碼片段如下:[code]
package domain;
//省略 import...
@Entity
@Table(uniqueConstraints = @UniqueConstraint(columnNames = "email"))
public class Member implements Serializable
{
//省略
}
[/code]因為專案是硬組出來的所以專案設定應該有所差異
打開專案設定進入 JPA 的項目,畫面如下圖:



紅色框就是問題原因
被設定成較為麻煩的模式,需要將所有 Entity class 列表設定在 persistence.xml 內
因為沒有設定所以當 Member class 加了 @Entity 就會出現警告

所以改成自動探索的設定之後就解決了錯誤訊息
頁: [1]

Powered by Discuz! X1.5 Archiver   © 2001-2010 Comsenz Inc.