无法移除版本标签,即使在pom.xml中有dependencyManagement。

huangapple go评论80阅读模式
英文:

Can't remove version tag even having dependencyManagement in pom.xml

问题

我正在尝试使用Spring Cloud创建一个发现微服务。我正在将 spring-cloud-dependencies-parent 作为POM添加以管理依赖项,但似乎我无法从其他依赖项中删除 version 标签。以下是 pom.xml 中的这部分内容:

    <dependencyManagement>

        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies-parent</artifactId>
                <version>2.2.1.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>

    </dependencyManagement>

    <dependencies>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
<!--            <version>1.4.7.RELEASE</version>-->
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
<!--            <version>${spring.boot.version}</version>-->
            <scope>test</scope>
        </dependency>

我可以取消注释 version 标签,一切都会编译正常,但似乎我在这里存在版本不匹配的问题,我更希望版本能够自动处理。有什么建议吗?

英文:

I'm trying to create a discovery microservice with spring cloud. I'm adding spring-cloud-dependencies-parent as pom to manage dependencies, but it seems I cannot remove version tag from other dependencies. Here's this part of pom.xml:

    &lt;dependencyManagement&gt;

        &lt;dependencies&gt;
            &lt;dependency&gt;
                &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
                &lt;artifactId&gt;spring-cloud-dependencies-parent&lt;/artifactId&gt;
                &lt;version&gt;2.2.1.RELEASE&lt;/version&gt;
                &lt;type&gt;pom&lt;/type&gt;
                &lt;scope&gt;import&lt;/scope&gt;
            &lt;/dependency&gt;
        &lt;/dependencies&gt;

    &lt;/dependencyManagement&gt;

    &lt;dependencies&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
            &lt;artifactId&gt;spring-cloud-starter-eureka-server&lt;/artifactId&gt;
&lt;!--            &lt;version&gt;1.4.7.RELEASE&lt;/version&gt;--&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
            &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
&lt;!--            &lt;version&gt;${spring.boot.version}&lt;/version&gt;--&gt;
            &lt;scope&gt;test&lt;/scope&gt;
        &lt;/dependency&gt;

I can just uncomment version tags and everything will compile fine, but it seems I have a version mismatch here and I'd prefer versions to be handled automatically. Any ideas?

答案1

得分: 3

spring-cloud-dependencies-parent 是一个父级 POM,没有任何依赖管理。可能只是拼写错误?请尝试以下代码:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-dependencies</artifactId>
      <version>Hoxton.SR1</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

提示:您可以访问 https://start.spring.io/#!dependencies=cloud-starter 并点击 "Explore" 来获取相同的信息。

英文:

spring-cloud-dependencies-parent is a parent pom with 0 dependency management. Probably just a typo? Try

  &lt;dependencyManagement&gt;
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
        &lt;artifactId&gt;spring-cloud-dependencies&lt;/artifactId&gt;
        &lt;version&gt;Hoxton.SR1&lt;/version&gt;
        &lt;type&gt;pom&lt;/type&gt;
        &lt;scope&gt;import&lt;/scope&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  &lt;/dependencyManagement&gt;

> Hint: you can go to https://start.spring.io/#!dependencies=cloud-starter and click on "Explore" to get the same information.

huangapple
  • 本文由 发表于 2020年1月6日 21:29:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/59613010.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定