Maven 使用插件安装本地 jar 包
1. 将本地 jar 包复制到项目中需要安装的模块 lab 文件夹下
2. 引用 maven-install-plugin 插件
在 pom.xml 文件中,增加 build 节点内容
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<!-- ID不可重复 -->
<id>install-local-jar</id>
<!-- maven clean 阶段执行 -->
<phase>clean</phase>
<goals>
<!-- 执行安装文件操作 -->
<goal>install-file</goal>
</goals>
<configuration>
<!-- jar 包位置 -->
<file>lib/local-jar-1.0.jar</file>
<repositoryLayout>default</repositoryLayout>
<generatePom>true</generatePom>
<!-- groupId artifactId version 和 maven Dependency 中一致 -->
<groupId>org.example</groupId>
<artifactId>local-jar</artifactId>
<version>1.0</version>
<!-- packaging 为 jar -->
<packaging>jar</packaging>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
3. 增加 maven 依赖
在 maven dependencies 中增加刚才配置的相关依赖
<dependency>
<groupId>org.example</groupId>
<artifactId>local-jar</artifactId>
<version>1.0</version>
</dependency>
4. 执行 maven 命令
执行 maven clean 命令即可将 lab 中的 jar 安装到本地 maven 仓库
5. 执行编译命令
执行编译命令
maven compile
[[Maven]]
[[SpringBoot]]
[[Java]]