日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無先后,達(dá)者為師

網(wǎng)站首頁 編程語言 正文

maven項(xiàng)目如何引入項(xiàng)目本地jar包

作者:明快de玄米61 更新時(shí)間: 2023-07-07 編程語言

目錄

    • 背景
    • 操作

背景

由于項(xiàng)目需要,對(duì)jar包中的內(nèi)容進(jìn)行了一點(diǎn)改變,但是由于不熟悉公司maven倉庫發(fā)布流程,所以就把jar包放到了項(xiàng)目中,那就需要將本地jar包交給maven管理

操作

在項(xiàng)目中新建目錄lib,然后將jar包放在其中,比如我的jar包名稱是:spire.doc.free-5.2.0.jar,如下所示:

在這里插入圖片描述

然后在pom.xml中的dependencies標(biāo)簽里面添加如下標(biāo)簽即可:

<dependency>
	<!-- 模塊原有g(shù)roupId -->
    <groupId>e-iceblue</groupId>
	<!-- 模塊原有artifactId -->
    <artifactId>spire.doc.free</artifactId>
	<!-- 模塊原有version -->
    <version>5.2.0</version>
	<!-- 系統(tǒng)依賴范圍,往往與本機(jī)綁定,不過我本次和項(xiàng)目中的jar包進(jìn)行了綁定 -->
    <scope>system</scope>
	<!-- 本地jar包絕對(duì)路徑,${project.basedir}是項(xiàng)目所在路徑,lib是我們新建的目錄,spire.doc.free-5.2.0.jar是jar包名稱 -->
    <systemPath>${project.basedir}/lib/spire.doc.free-5.2.0.jar</systemPath>
</dependency>

由于上述依賴的scope屬性是system(系統(tǒng)依賴范圍),該依賴范圍只在編譯、測(cè)試時(shí)有效,但是在運(yùn)行時(shí)無效,詳細(xì)解釋請(qǐng)看:《Maven實(shí)戰(zhàn)》P64 表5-1“依賴范圍與classpath的關(guān)系”

對(duì)于springboot項(xiàng)目來說,如果在打包時(shí)想要將scope屬性為system的jar包打包,那就需要在pom.xml中添加以下配置:

注意:以下為pom.xml文件中的配置
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <!-- start 允許引入本地jar包 -->
            <configuration>
                <includeSystemScope>true</includeSystemScope>
            </configuration>
            <!-- end 允許引入本地jar包 -->
        </plugin>
        ……
    </plugins>
    ……
</build>

原文鏈接:https://blog.csdn.net/qq_42449963/article/details/131496049

  • 上一篇:沒有了
  • 下一篇:沒有了
欄目分類
最近更新