在没有 maven install:install-file 的情况下添加 maven 本地依赖项

Adding maven local dependecies without mvn install:install-file

我的基本路径下的文件夹 /src/main/resources/foobar 中有一些本地 jar 文件。

我将它们作为依赖项包含在我的 POM.xml:

<dependency>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-models</artifactId>
    <version>1.5.4-SNAPSHOT</version>
</dependency>

现在我尝试使用本地存储库添加它们:

<repositories>
    <repository>
        <id>resource-repository</id>
        <url>file://${project.basedir}/repo</url>
    </repository>
</repositories>

现在我仍然收到错误消息,指出未找到此存储库中的罐子:

The following artifacts could not be resolved: bar... in file://.../repo was cached in the local repository, resolution will not be reattempted until the update interval of resource-repository has elapsed or updates are forced -> [Help 1]

我没用过

mvn install:install-file

命令。如果有一个我不需要这样做的解决方案,我会很高兴。

编辑:

文件夹结构为:

repo\io\swagger\swagger-models.5.4-SNAPSHOT

和里面的罐子:

swagger-models-1.5.4-SNAPSHOT.Jar

有趣的是,当 运行 安装 maven 时,我收到有关此文件缺少 POM 的警告。

您可以为您的第三方依赖项声明一个存储库。

依赖项必须放在 repoBase 路径中,jar 的目录必须遵循以下模式:“{groupId}/{artifactId}/{artifactVersion}”。在此文件夹中,jar 必须命名为“{artifactId}-{artifactVersion}.jar”。

示例:

<dependencies>
  <dependency>
    <groupId>foo</groupId>
    <artifactId>bar</artifactId>
    <version>1.0</version>
  </dependency>
</dependencies>

<repositories>
<repository>
    <id>resource-repository</id>
    <url>file:${project.basedir}/repo</url>
</repository>


我的 pom 中有这个(当然还有项目标签和组 ID 等)
然后我的项目目录中有一个目录 repo。
在路径 "repo\foo\bar.0" 中,此目录中有一个 "bar-1.0.jar" 文件。这为我编译(好的,jar 是空的,但这对于示例来说无关紧要)。
请注意,存储库的 url 不包含 "file:".
之后的两个斜杠 我希望这个例子对于尝试这个的人来说更容易理解。

我建议您在依赖标签中使用系统标签。希望有用。