package names (namespaces) in subproject classes in Play Framework

前端 未结 1 1336
陌清茗
陌清茗 2021-01-15 18:01

I am trying to create multi submodule project in PlayFramework (play framework 2.2.1).

How should I name package in submodules?

F.E. I have structure as foll

1条回答
  •  深忆病人
    2021-01-15 18:45

    I've found solution.

    It dosn't matter how I named packages. One requirement from play framework is to start name of package with:

    • controllers - in case of naming controller package (f.e: package controllers.common;)
    • models - in case of naming model package (f.e: package models.common;, or just package models; )

    Runtime error:

    [IllegalArgumentException: Unknown entity: models.Cart]
    

    Is caused by Jpa/Hibernate configuration. Problem is that Jpa/Hibernate sees my entities (mark by annotation @Entity) while compilation, but in runtime dosn't. To fix that I've to manually point all my models class (entitites) in persistance.xml file as follow:

    /conf/META-INF/persistence.xml

    
    
        
            org.hibernate.ejb.HibernatePersistence
            DefaultDS
                models.AppMode
                models.Customer
                models.Complaint
            
                
                
                
            
        
    
    

    See more here: How to persist models entity in playframework submodule using jpa/hibernate

    0 讨论(0)
提交回复
热议问题