Spring Boot(和 Web)多模块项目
我正在尝试创建一个多模块 Spring Boot 项目(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.)
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,您可以有 5 个 pom.xml 文件。每个模块(包括父模块)都有自己的 pom.xml。
我们对于 spring-boot 应用程序有类似的项目结构。我们在父 pom 中有 spring-boot-starter-parent ,在需要的各个模块中有其他库,例如数据访问等。
You can have 5 pom.xml files in this case. Each module (including parent) will have its own pom.xml.
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.