【问题标题】:Invalid spring-boot-dependency version when using jgitver and local repo in maven在 maven 中使用 jgitver 和本地 repo 时 spring-boot-dependency 版本无效
【发布时间】:2020-04-09 13:35:06
【问题描述】:

当我将 spring-boot-starter-parent 与本地存储库和 jgitver 结合使用时,我收到以下错误:

[ERROR]   The project tmplsvcpkg:TMPL_SVC_NAME-parent:0.0.0-27-a592e4fb-feature_gitlabci-dirty (/home/user/git/service-template/pom.xml) has 1 error
[ERROR]   Non-resolvable parent POM for org.springframework.boot:spring-boot-starter-parent:[unknown-version]: Could not find artifact org.springframework.boot:spring-boot-dependencies:pom:0.0.0-27-a592e4fb-feature_gitlabci-dirty in internal-repository (https://mvnrepo) @ org.springframework.boot:spring-boot-starter-parent:[unknown-version], /home/user/git/service-template/.m2/repository/org/springframework/boot/spring-boot-starter-parent/2.2.0.RELEASE/spring-boot-starter-parent-2.2.0.RELEASE.pom, line 3, column 11 -> [Help 2]

注意 unknown-version 用于 spring-boot-starter-parent 和 0.0.0-27-a592e4fb-feature_gitlabci-dirty 用于 spring-boot-dependencies。 0.0.0-27-...版本是jgitver计算出来的版本。看起来版本分辨率以某种方式搞砸了。如果我将本地存储库更改为项目之外的任何目录,它会再次开始工作。如果我抑制 jgitver,它会再次开始工作。如果我在项目中更深入地定义本地存储库(例如 maven.repo.local=x/y/z/.m2/repository,错误仍然存​​在。

我以这种方式在 pom.xml 中定义了父级:

        <parent>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-parent</artifactId>
                <version>2.2.0.RELEASE</version>
        </parent>

我以这种方式运行我的 maven:

mvn compile -Dmaven.repo.local=.m2/repository -U

如果我添加 jgitver.skip=true,一切正常。

我怀疑这可能与 spring-boot-starter 父级将其父级(spring-boot-dependencies)定义为相对于其位置的事实有关:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-dependencies</artifactId>
    <version>2.2.0.RELEASE</version>
    <relativePath>../../spring-boot-dependencies</relativePath>
</parent>

有人知道为什么会发生这种情况以及如何解决吗?

【问题讨论】:

  • 可能您的本地仓库已损坏。
  • 这似乎不是一个案例,因为我在每次测试之前都删除了本地 repo,无论我重复多少次,结果都是一样的。 Jgitver + 项目内的本地 repo = 错误,jgitver + 项目外的本地 repo = 成功。
  • 对不起,我无能为力。从未使用过Jgitver。请问你为什么用它?
  • 它根据它在 git 结构中的位置计算 maven 工件的版本。分支获得不同的版本,未提交的 repos 获得不同的版本,标签获得不同的版本。这是确保版本在整个项目中保持一致并且反映工件的实际版本的好方法。

标签: spring-boot maven jgitver


【解决方案1】:

事实证明这是一个众所周知的问题,并且可以通过插件的特定配置来解决(您必须在插件配置中排除 .m2 目录)。本期有更多详细信息:

https://github.com/jgitver/jgitver-maven-plugin/issues/60

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-12
    • 2014-07-03
    • 2020-07-23
    • 1970-01-01
    • 2021-08-02
    • 2022-01-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多