maven dependencyManagement 子模塊不寫版本號無法引入


現象

在父模塊中使用 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>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM