简体   繁体   中英

Spring boot (and web) multi module project

I'm attempting to create a multi-module spring boot project (a rewrite of a Struts2/Ibatis project) that I wish to lay out as follows:

-- 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

How can I set up each pom so that:

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.)

Thank you.

You can have 5 pom.xml files in this case. Each module (including parent) will have its own pom.xml.

  1. Parent pom file can have all the properties that can be shared in the child modules
  2. If you have more than one module that uses the the spring-boot-starter-parent dependency then it make senses to have it in the parent pom else you can have it in the module where its needed.
  3. If can you module specific dependencies in each pom for optimization.

We have similar project structure for spring-boot application. We have the spring-boot-starter-parent in the parent pom and other libraries like data access etc. in individual modules where its needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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