DDD、JPA 和多模块专家
2022-09-04 04:48:55
我正在尝试使用Spring / JPA配置和Maven多模块项目。下面是总体布局。我有一个包含5个子模块的根模块。
backoffice (root maven module) | -(maven module)-----core (this is where persistence.xml and entityManager stuff resides). | -(maven module)-----employee (employee related entities, controllers, etc.) | -(maven module)-----vendor (vendor related entities, controllers, etc.) | -(maven module)-----customer (customer related entities, controllers, etc.) | -(maven module)-----web (contains all the web stuff).
我在core/src/main/resources/META-INF(持久性.xml,spring-context w/ EntityManagerFactory,dataSource等)中拥有所有jpa的东西。这个想法是我想在所有子模块(员工,供应商和客户)中共享持久性的东西。
问题是,当 Web 应用启动时,它找不到 EntityMangerFactory。如果我在每个子模块(员工,供应商和客户)中设置JPA的东西,那么它就可以工作了。
如何在核心中设置所有与持久性相关的东西,然后在其他模块之间共享?
提前致谢。