gpt4 book ai didi

java - DDD、JPA 和多模块 Maven

转载 作者:IT老高 更新时间:2023-10-28 13:57:57 25 4
gpt4 key购买 nike

我正在尝试使用 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 中拥有所有 jpa 内容(persistence.xml、spring-context w/EntityManagerFactory、dataSource 等)。我的想法是我想在所有子模块(员工、供应商和客户)之间共享持久性内容。

问题是当 web 应用程序启动时,它找不到 EntityMangerFactory。如果我在每个子模块(员工、供应商和客户)中设置 JPA 内容,那么它就可以工作。

如何在核心中设置所有与持久性相关的内容,然后在其他模块中共享?

提前致谢。

最佳答案

好吧,这是我最终使用的解决方案,以防有人感兴趣。

http://labs.bsb.com/2010/11/configuring-modular-jpa-applications-with-spring/

一些响应者问我为什么要首先以这种方式设置项目。原因是模块化。我希望一切都在小型可测试和可部署的单元中。最终,我们会将 OSGI 融入其中,以便客户可以选择他们想要安装的模块。每个模块都必须能够独立运行。

关于java - DDD、JPA 和多模块 Maven,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4298012/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com