maven编译时引入外部jar

<!-- 1.添加对工程lib目录中jar的编译 -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-compiler-plugin</artifactId>

<configuration>

<source>1.8</source>

<target>1.8</target>

<encoding>UTF-8</encoding>

<compilerArguments>

<extdirs>${project.basedir}/src/main/resources/lib</extdirs>

</compilerArguments>

</configuration>

</plugin>

<!-- 2.编译时引入独立jar包 -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-compiler-plugin</artifactId>

<configuration>

<source>1.8</source>

<target>1.8</target>

<encoding>UTF-8</encoding>

<compilerArguments>

<verbose />

<!-- 替换为所引用jar的路径 -->

<bootclasspath>${JAVA_HOME}\jre\lib\rt.jar</bootclasspath>

</compilerArguments>

</configuration>

</plugin>

也可以使用下面的方式

  1. <dependency>
  2. <groupId>com.example</groupId>
  3. <artifactId>your-artifact-id</artifactId>
  4. <version>1.0.0</version>
  5. <scope>system</scope>
  6. <systemPath>${project.basedir}/libs/your-jar-file.jar</systemPath>
  7. </dependency>
相关推荐
Despacito10068 分钟前
Java后端性能探查工具速查表
java·开发语言
晊晌_h32 分钟前
嵌入式从0到精通——Linux C|TCP 并发服务器实现方案详解
服务器·开发语言·tcp/ip
传奇开心果编程43 分钟前
【Rust入门知识点学与练】第17课:闭包 Closures
开发语言·学习·rust
广州灵眸科技有限公司1 小时前
从手动三步到上电即连:4G模组systemd开机自连方案
linux·运维·服务器·开发语言·网络·人工智能·php
今夜有雨.1 小时前
C# 学习文档(零基础入门)
开发语言·学习·c#
触底反弹2 小时前
面试被问到 Text2SQL,我用 DeepSeek 自己实现了一个
python·sqlite
2601_962295582 小时前
python+selenium实现自动化测试
自动化测试·python·selenium·学习心得·web端测试
软件黑马王子2 小时前
14.事件中心:主要作用和原理
开发语言·前端框架·c#
青 春 记 忆2 小时前
零基础入门python66:FastAPI AI标题、摘要和标签
python·fastapi·后端开发