对于本地jar的maven引用,在不方便使用私有maven仓库的情况下,
使用SystemPath方式引用还是比较合适的,这里以uid-generator-1.0.0-SNAPSHOT.jar这个本地包为例。
1.将打好的包拷贝到项目中:
2.修改pom.xml引入:
<dependency>
<groupId>com.baidu.fsg</groupId>
<artifactId>uid-generator</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/uid-generator-1.0.0-SNAPSHOT.jar</systemPath>
</dependency>
注意:
groupId:自定义
artifactId:自定义
version:自定义
scope:必须是system
systemPath:jar包的路径
3.增加pom.xml编译打包引入jar:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>${project.basedir}/lib</directory>
<targetPath>BOOT-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<targetPath>BOOT-INF/classes/</targetPath>
</resource>
</resources>
</build>