目前我正在一个项目中工作,该项目在一个父 pom 下包含 260 个 Maven 子模块。这似乎会减慢构建速度。这就是为什么我提出了这个问题:什么时候应该使用子模块,什么时候不应该使用它。
最佳答案
If you have several Maven projects, and they all have similar configurations, you can refactor your projects by pulling out those similar configurations and making a parent project. Thus, all you have to do is to let your Maven projects inherit that parent project, and those configurations would then be applied to all of them.
And if you have a group of projects that are built or processed together, you can create a parent project and have that parent project declare those projects as its modules. By doing so, you'd only have to build the parent and the rest will follow.
在以下情况下创建子模块:
- 项目共享相同的配置,以避免配置重复
- 项目相互关联,让构建变得更容易
关于java - 何时创建 Maven 子模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56881744/