spring-boot多个模块如何管理多重继承关系
项目中有A
、B
、C
、D
、E
这五个项目,
其中A
打算作为其余四个项目的父模块,用来管理依赖,其余的四个项目打算都是用spring-boot
来开发,请问这个依赖关系我如何在pom.xml
中去定义?
我说一下我目前的方案
A:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
</parent>
<modules>
<module>../B</module>
<module>../C</module>
<module>../D</module>
<module>../E</module>
</modules>
<packing>pom</packing>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
B:
<parent>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<relativePath>../A/pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
其余的C、D、E的pom.xml
与B类似,我这样配置后,B提示我spring-boot-starter-web
要指定版本号,B的父级模块已经有了spring-boot-starter-web
这个依赖,并且版本号也已经可以从spring-boot-starter-parent
这个模块来获取,为什么会出现找不到版本号呢?
还有如果我不使用spring-boot-starter-parent
只使用spring-boot-starter-web
时项目依然可以运行这是为啥?spring-boot
项目不依赖spring-boot-starter-parent
吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在A项目中的pom不需要添加这个依赖管理,你的子模块中需要spring-boot-starter-web这个依赖的话直接添加在子模块的pom上就可以了,不需要指定版本,版本是根据你A项目的spring-boot-starter-parent的版本的。
说明pom关系没对应上,我理解不用整什么相对路径的,直接用IDE创建多模块项目吧