在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,就可以提交了。