gpt4 book ai didi

java - Maven 项目中的非 Maven 依赖项

转载 作者:行者123 更新时间:2023-12-02 06:21:14 24 4
gpt4 key购买 nike

如何在 IntelliJ IDEA 中添加外部 jar 文件作为 Maven 项目的依赖项?因为当我将其添加到依赖项列表中并尝试使用 Maven 进行编译时,我收到错误,指出无法找到该依赖项。

最佳答案

您可以

  • 像这样定义系统/本地依赖项:

    <dependency>
    <groupId>example</groupId>
    <artifactId>example</artifactId>
    <version>1.0.0</version>
    <scope>system</scope>
    <systemPath>lib/example-1.0.0.jar</systemPath>
    </dependency>

正如 Gimby 指出的那样,请注意系统依赖项应该“就在那里”,因此它们不会与您的 Artifact 一起打包和部署。请参阅this question供引用。

  • 将 Artifact 安装到本地存储库中:

    mvn install:install-file -Dfile=<path-to-file> \
    -DgroupId=<myGroup> \
    -DartifactId=<myArtifactId> \
    -Dversion=<myVersion> \
    -Dpackaging=<myPackaging> \
    -DlocalRepositoryPath=<path-to-my-repo>

关于java - Maven 项目中的非 Maven 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20993038/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com