我有一个很好的Spring项目。现在,由于需要在另一个项目中使用现有项目的一部分,我需要将项目拆分成两个部分。在拆分过程中,我遇到了一个问题,但我不理解这个问题的来源,也不知道该如何解决。例如:
+ -- myTestProject
| -- PersonEntity
| -- persistence.xml
| -- pom.xml
+ -- myBaseProject
|
| -- PhoneEntity
| -- pom.xml
当我将PhoneEntity保存在myTestProject
中时,可以顺利启动Tomcat。当我像上面那样分离实体时,我会从EclipseLink
收到以下错误信息:
对于实体类[class com.smith.Company]上的属性[phoneEntity]的类型[class com.smith.PhoneEntity]不是可序列化映射的有效类型。属性类型必须实现Serializable接口。
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="eclipselink" transaction-type="RESOURCE_LOCAL">
<description>Application managed persistence unit</description>
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<non-jta-data-source>java:comp/env/jdbc/ecoiDS</non-jta-data-source>
<class>com.smith.PersonEntity</class>
<class>com.smith.PhoneEntity</class>
<class>com.smith.Company</class>
<properties>
<property name="eclipselink.logging.level" value="WARNING" />
<property name="eclipselink.logging.timestamp" value="true" />
<property name="eclipselink.logging.session" value="false" />
<property name="eclipselink.logging.thread" value="false" />
<property name="eclipselink.logging.exceptions" value="true" />
<property name="eclipselink.weaving" value="static"/>
<property name=""/>
</properties>
</persistence-unit>
</persistence>
persistence.xml
文件已经包含了PhoneEntity
。整个项目编译正常,但是无法启动项目。是否有任何提示可以解决这个问题?
persistence.xml
的相关部分。答案可能就在那里。 - davidxxxpersistence.xml
。 - LeO