您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Play框架中子项目类中的程序包名称(命名空间)

Play框架中子项目类中的程序包名称(命名空间)

我找到了解决方案。

我如何命名软件包都没关系。播放框架的一项要求是,以以下名称开头包的名称

运行时错误

[IllegalArgumentException: UnkNown entity: models.Cart]

是由Jpa /休眠配置引起的。问题在于,Jpa / Hibernate在编译时会看到我的实体(通过@Entity标记),但在运行时却看不到。要解决此问题,我必须手动将所有模型类(实体)指向persistance.xml文件,如下所示:

/conf/Meta-INF/persistence.xml

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
             version="2.0">

    <persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <non-jta-data-source>DefaultDS</non-jta-data-source>
            <class>models.AppMode</class>
            <class>models.Customer</class>
            <class>models.Complaint</class>
        <properties>
            <property name="hibernate.hbm2ddl.auto" value="update"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
            <property name="hibernate.show_sql" value="true"/>
        </properties>
    </persistence-unit>
</persistence>

在此处查看更多信息:如何使用jpa / hibernate将模型实体持久化在playframework子模块中

其他 2022/1/1 18:31:29 有436人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶