You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在IntelliJ中配置Maven本地依赖以避免被自动移除?

将本地Jar包配置为Maven依赖的解决方案

方法一:安装到本地Maven仓库(推荐)

这种方式能让Maven像处理中央仓库依赖一样管理这个Jar包,彻底避免刷新时丢失的问题:

  • 打开终端(Windows用命令提示符),执行以下命令(替换/path/to/为你的Jar包实际路径,groupId、artifactId和version可按项目惯例自定义):
mvn install:install-file -Dfile=/path/to/OpenXES-20211004.jar -DgroupId=org.openxes -DartifactId=openxes -Dversion=20211004 -Dpackaging=jar
  • 安装完成后,在项目pom.xml中添加依赖声明:
<dependency>
    <groupId>org.openxes</groupId>
    <artifactId>openxes</artifactId>
    <version>20211004</version>
</dependency>

之后执行Maven刷新操作,该依赖会稳定存在,不会被其他依赖安装操作移除。

方法二:项目内本地Lib目录配置

如果不想把Jar包安装到本地仓库,可将其放在项目内部目录进行管理:

  1. 在项目根目录创建lib文件夹,将OpenXES-20211004.jar复制进去。
  2. 在pom.xml中添加依赖配置:
<dependency>
    <groupId>org.openxes</groupId>
    <artifactId>openxes</artifactId>
    <version>20211004</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/lib/OpenXES-20211004.jar</systemPath>
</dependency>
  1. 若需要让Maven编译时包含该system依赖,在pom.xml的build节点下补充配置:
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>1.8</source> <!-- 替换为你项目使用的JDK版本 -->
                <target>1.8</target>
                <includeSystemScope>true</includeSystemScope>
            </configuration>
        </plugin>
    </plugins>
</build>

内容的提问来源于stack exchange,提问作者BOGDAN DONICI

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 14:30:57