Maven:如何使用本地 lib 目录作为依赖项而不是 Maven 存储库

sre*_*611 6 maven-3 maven maven-surefire-plugin maven-dependency

我在集成测试期间的项目结构如下。

 Project-A
    |_conf (contains the configuration files)
    |_lib  (Contains the all dependencies)
    |_pom.xml
    |_target
        |_test (Contains the integration tests)
Run Code Online (Sandbox Code Playgroud)

当我运行下面的 maven 命令时,它从 nexus 下载依赖项并指向本地存储库而不是 lib 目录。

如何告诉 Maven 检查lib文件夹中的依赖项而不是本地 Maven 存储库?

注意:lib包含测试项目所需的所有依赖项。

    mvn surefire:test
Run Code Online (Sandbox Code Playgroud)

Dee*_*mar 9

如果您想使用不在 Maven 存储库中的依赖项,那么您可以将这些 jar 放在项目中(在您的情况下为 lib 目录)。并指定要使用的 jar 的路径,如下所示。

<dependency>
    <groupId>anything</groupId>
    <artifactId>anything</artifactId>
    <version>anything</version>
    <scope>system</scope>
    <systemPath>${basedir}/lib/jar-name.jar</systemPath>
</dependency>
Run Code Online (Sandbox Code Playgroud)

在这里您可以提及groupId,artifactId和的任何内容version。在这种情况下,这些字段将被忽略。