繁体   English   中英

Spring 引导(和网络)多模块项目

[英]Spring boot (and web) multi module project

我正在尝试创建一个多模块 spring 引导项目(Struts2/Ibatis 项目的重写),我希望将其布局如下:

-- Parent project.  //contains <properties> that should be shared through the child modules
 |- model //Contains ONLY Hibernate entities
 |- dataaccess //uses 'model' but has dataManagers and dataRepositories with Spring @Autowired beans
 |- webapp //uses 'dataaccess' module and uses Spring @Controller for processing requests
 |- scheduled //Spring boot console app that runs once a day, uses 'dataaccess' module for DB read writes

我如何设置每个 pom,以便:

1 - <properties> only need to be set in one pom but are accessible to the other modules
2 - Where should I use <parent> <artifactId>spring-boot-starter-parent or should I somehow access the spring boot modules in some other way?
3 - How can I optimise the pom heirarchy so that only the necessary libraries are exposed to the relevant module (i.e. in the 'model' module there will be no need to have access to spring-boot-starter-web etc.)

谢谢你。

在这种情况下,您可以有 5 个 pom.xml 文件。 每个模块(包括父模块)都有自己的 pom.xml。

  1. 父 pom 文件可以拥有所有可以在子模块中共享的属性
  2. 如果您有多个模块使用 spring-boot-starter-parent 依赖项,那么将它放在父 pom 中是有意义的,否则您可以将它放在需要的模块中。
  3. 如果您可以在每个 pom 中模块化特定的依赖项以进行优化。

对于 spring-boot 应用程序,我们有类似的项目结构。 我们在父 pom 中有 spring-boot-starter-parent ,在需要的各个模块中有其他库,如数据访问等。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM