bestlong 怕失憶論壇

 

 

搜索
bestlong 怕失憶論壇 論壇 Java Eclipse Class is mapped, but is not included in any persiste ...
查看: 2219|回復: 1
go

Class is mapped, but is not included in any persistence unit [複製鏈接]

Rank: 9Rank: 9Rank: 9

1#
發表於 2013-5-8 10:12 |只看該作者 |倒序瀏覽 |打印
在 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 後修改而來的
我是雪龍
http://blog.bestlong.idv.tw
http://www.bestlong.idv.tw

Rank: 9Rank: 9Rank: 9

2#
發表於 2013-5-8 10:39 |只看該作者
錯誤訊息是 Eclipse 所識別出來的
Member.java 程式碼片段如下:
  1. package domain;
  2. //省略 import...
  3. @Entity
  4. @Table(uniqueConstraints = @UniqueConstraint(columnNames = "email"))
  5. public class Member implements Serializable
  6. {
  7. //省略
  8. }
複製代碼
因為專案是硬組出來的所以專案設定應該有所差異
打開專案設定進入 JPA 的項目,畫面如下圖:

JPA Problem.png

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

所以改成自動探索的設定之後就解決了錯誤訊息
我是雪龍
http://blog.bestlong.idv.tw
http://www.bestlong.idv.tw
‹ 上一主題|下一主題

Archiver|怕失憶論壇

GMT+8, 2024-4-20 03:34 , Processed in 0.013934 second(s), 13 queries .

Powered by Discuz! X1.5

© 2001-2010 Comsenz Inc.