2016-09-08 4 views
0

を宣言したのpersistence.xml:JPAエンティティとのpersistence.xml使用し</p> <p>JPA-モジュール..私は私のアプリで異なる分離したモジュールを使用している別のモジュールで

残りのモジュールが含まれています。Iをデータを永続化するためにJAX-RSサービスとHibernateを使用しています...

Guiceを使用してentitymanagerを注入していますが、エラーが発生します(rest-moduleの下にpersistence.xmlを置かないと)

2016-09-07 22:09:06.704:WARN:oejw.WebAppContext:main: Failed startup of context [email protected]{/services,file:///Users/rest-module/target/rest-module-1.0-SNAPSHOT/,STARTING}{../rest-module/target/rest-module-1.0-SNAPSHOT} 
javax.persistence.PersistenceException: No Persistence provider for EntityManager named local_persist_unit 
ここ

は私のpersistence.xmlの内容です:

<persistence-unit name="local_persist_unit" transaction-type="RESOURCE_LOCAL"> 
     <provider>org.hibernate.ejb.HibernatePersistence</provider> 
     <properties> 

      <!--PostgreSQL--> 
      <property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/> 
      <property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/postgres"/> 
      <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/> 
      <property name="hibernate.connection.username" value="postgres"/> 
      <property name="hibernate.connection.password" value="postgres"/> 
      <property name="hibernate.archive.autodetection" value="class"/> 
      <property name="hibernate.id.new_generator_mappings" value="true"/> 
      <property name="hibernate.hbm2ddl.auto" value="create-drop"/> 
      <property name="hibernate.ejb.metamodel.generation" value="disabled"/> 
      <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.DefaultComponentSafeNamingStrategy"/> 
      <property name="hibernate.show_sql" value="true"/> 
     </properties> 

    </persistence-unit> 

Hibernateはpersistence.xmlファイルを見つけることができなかった理由を任意のアイデア?

答えて

0

Mavenマルチモジュールプロジェクトでは、REST、Service、DAL、またはnレイヤに異なるモジュールがある場合、異なるモジュールにパーシスタンスユニットを定義できます。

Example : Github projectここで、persistence.xmlはRESTレイヤーに関係なくdalレイヤーで定義されています。

クラスパスが

依存関係の階層があるだろうどのようにこれまで、
dal/src/main/resources/META-INF 

にXMLを追加することで認識していることを確認し、

REST -> Service -> Dal 
関連する問題