maven項目引入本地jar包,並push到git


在main下創建目錄lib

1、把jar包復制到lib目錄下

2、在pom文件中添加依賴如下

當scope值為system時,項目依賴取systemPath路徑下的jar包

        <dependency>
            <groupId>com.jd.open.api</groupId>
            <artifactId>open-api-sdk</artifactId>
            <scope>system</scope>
            <systemPath>${project.basedir}/src/main/lib/open-api-sdk-2.0.jar</systemPath>
        </dependency>

3、當scope為system的時候,打包不會自動打包進去,需要添加一個參數

                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${spring-boot-maven-plugin.version}</version>
            <!--當scope為system時增加配置--> <configuration> <includeSystemScope>true</includeSystemScope> </configuration> </plugin>

4、提交jar到git中

  4.1、maven項目idea默認會把jar給過濾掉

  去掉maven項目下的.gitignore文件的 *.jar,*.lib,就可以提交了。

  

 

 

  


免責聲明!

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



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