简体   繁体   English

春天的多个持久性文件

[英]Multiple persistence files in spring

I'm trying to create multiple modules with multiple persistence xml files. 我正在尝试使用多个持久性xml文件创建多个模块。 Idea is to keep entity classes inside same module it belongs to. 想法是将实体类保留在它所属的相同模块内。

Module 'A' configured with JPA with persistence.xml and working fine. 使用Persistence.xml和JPA配置的模块'A'正常工作。 Module 'B' has dependency with Module 'A' and has its own persistence.xml. 模块“ B”与模块“ A”具有依赖性,并且具有自己的persistence.xml。

When I try to use I get 当我尝试使用时,我得到

 IllegalStateException:Conflicting persistence unit definitions for name in

I'm building this test app with spring roo. 我正在用Spring Roo构建这个测试应用程序。 Please shed a light on this. 请阐明这一点。 cheers 干杯

Review the persistance unit names in each persistence.xml 查看每个persistence.xml中的持久性单元名称

Something like persistanceUnit for the Module A (that works fine) and persistanceUnitB for Module B. 类似于ModuleA的persistanceUnit(可以正常工作)和Module B的persistanceUnitB。

Besides, you'll have to asign the appropriate persistance unit to each Entity. 此外,您必须为每个实体分配适当的持久性单元。 You can use the corresponding attribute in the Roo annotation 您可以在Roo批注中使用相应的属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 具有多个持久性单元的Spring JpaRepository - Spring JpaRepositories with multiple persistence units Spring,OpenJPA,多个持久性单元 - Spring, OpenJPA, multiple persistence unit 具有不同上下文配置的多个Spring集成测试文件会阻止持续的持久性 - Multiple Spring integration test files with different context configs prevents successul persistence 使用Spring的Hibernate JPA Persistence多数据库 - Hibernate JPA Persistence multiple database with Spring 具有多个持久性单元的Spring JPA ORM关系 - Spring JPA ORM relationships with multiple persistence units 在Maven Spring项目中将不同的属性文件加载到persistence.xml中 - Loading different properties files into persistence.xml in a maven spring project 使用单独的persistence.xml文件进行生产并使用Spring 3.1进行测试 - Using separate persistence.xml files for production and test with Spring 3.1 将多个持久性单元与服务器提供的数据源一起使用,其中包含 Spring 和 JPA - Using multiple persistence unit with server provided datasource with Spring and JPA Spring Data JPA - 作为JUnit运行的多个持久性单元,但不在Tomcat中 - Spring Data JPA - Multiple Persistence Units working as JUnit, but not in Tomcat 具有多个JPA持久性单元的Spring注释配置不持久 - Spring Annotation Config with Multiple JPA Persistence Units Doesn't Persist
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM