maven使用本地jar並打包
阿新 • • 發佈:2020-11-19
1.maven使用本地jar
在當前的工程建立一個lib資料夾,然後把jar檔案扔進去。
修改pom.xml
<dependency> <groupId>unidbg-api</groupId> <artifactId>unidbg-api</artifactId> <version>0.9</version> <scope>system</scope> <systemPath>${project.basedir}/lib/unidbg-api-0.9.0-SNAPSHOT.jar</systemPath> </dependency>
解釋
scope:程式碼載入本地的
systemPath是找本工程下面的lib資料夾下的對應jar檔案
這兩個必須寫的,否則會載入遠端倉庫的jar包切記。
2.打包的時候如果含有本地的jar依賴會無法直接打入
此時使用
<includeSystemScope>true</includeSystemScope>
完整的pom檔案如下
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.4.0</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.spider</groupId> <artifactId>unidbg-server</artifactId> <version>0.0.1-SNAPSHOT</version> <name>unidbg-server</name> <description>r Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>5.2.10.RELEASE</version> </dependency> <dependency> <groupId>net.java.dev.jna</groupId> <artifactId>jna</artifactId> <version>4.1.0</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.4</version> </dependency> <dependency> <groupId>com.github.zhkl0228</groupId> <artifactId>keystone</artifactId> <version>0.9.2</version> </dependency> <dependency> <groupId>com.github.zhkl0228</groupId> <artifactId>capstone</artifactId> <version>3.0.8</version> </dependency> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.6</version> </dependency> <dependency> <groupId>com.github.zhkl0228</groupId> <artifactId>unicorn</artifactId> <version>1.0.9</version> </dependency> <dependency> <groupId>unidbg</groupId> <artifactId>unidbg</artifactId> <version>0.9</version> <scope>system</scope> <systemPath>${project.basedir}/lib/unidbgok.jar</systemPath> </dependency> <dependency> <groupId>unidbg-api</groupId> <artifactId>unidbg-api</artifactId> <version>0.9</version> <scope>system</scope> <systemPath>${project.basedir}/lib/unidbg-api-0.9.0-SNAPSHOT.jar</systemPath> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skipTests>true</skipTests> </configuration> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.0.1.RELEASE</version> <configuration> <fork>true</fork> <mainClass>com.crack.DouyinSign</mainClass> <includeSystemScope>true</includeSystemScope> <!-- <finalName>unidbg0.9</finalName>--> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>