現象
在父模塊中使用 dependencyManagement 來控制子模塊按需引入jar包 而不是照盤全收
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
但是在子模塊中繼承父類並引入jar包的時候
<parent>
<groupId>cn.o</groupId>
<artifactId>atlas-cloud</artifactId>
<version>1.0.0</version>
</parent>
卻發現
無法引入這個jar包3
解決
在子模塊中按需引入 需要和父模塊一樣用 dependencyManagement
<dependencyManagement>
<dependencies>
<!--gateway-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
</dependencies>
</dependencyManagement>