英文:
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
:
<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>
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
<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>
> Hint: you can go to https://start.spring.io/#!dependencies=cloud-starter and click on "Explore" to get the same information.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论