maven專案引入本地jar包,並push到git
阿新 • • 發佈:2022-04-02
在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,就可以提交了。