对于几乎在每个模块都需要引用的依赖,去各自的模块配置中添加太麻烦了,就想着在父模块中添加,然后在子模块中继承就可以了。首先,需要注意:

父模块中要有对应的模块标签:

<modules>
	<module>my-querydsl-web</module>
	<module>my-querydsl-service</module>
	<module>my-querydsl-entity</module>
</modules>

子模块要指定对应的父模块标签:

<parent>
	<groupId>com.wzh</groupId>
	<artifactId>my-querydsl</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<relativePath/>
</parent>

这样父模块中添加的依赖在子模块中就可以直接使用

另外需要注意的区别,如下依赖可以被子模块继承

<dependencies>
	<dependency>
		<groupId>com.alibaba</groupId>
		<artifactId>fastjson</artifactId>
		<version>1.2.70</version>
	</dependency>
</dependencies>

下面标签的依赖不会被子模块继承

<dependencyManagement>
	<dependencies>
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>fastjson</artifactId>
			<version>1.2.70</version>
		</dependency>
	</dependencies>
</dependencyManagement>

 

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐