英文:
Maven - Unable to resolve maven dependency locally for version range
问题
我正在尝试编译一个名为 web-server 的Maven项目,它依赖于 search-client,依赖版本范围为 [2.0,3.0)。但是编译失败,因为存储库中出现了"指定范围内无法找到版本 > com.test.search:search-client:jar:[2.0,3.0)" 的错误。
以下是我正在执行的步骤:
- 进行更改并在本地构建 search-client
这将在我的本地m2存储库中为此客户端pom构建一个2.0-SNAPSHOT的jar文件。
- 尝试构建依赖于上述搜索客户端的web-server
这不会编译,出现以下错误:
[ERROR] Failed to execute goal on project common: Could not resolve
dependencies for project com.test.web:common:jar:2.0-SNAPSHOT: Failed
to collect dependencies at
com.test.search:search-client:jar:[2.0,3.0): No versions available for
com.test.search:search-client:jar:[2.0,3.0) within specified range ->
[Help 1]
Web Server POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>web-parent</artifactId>
<groupId>com.test.web</groupId>
<version>2.0-SNAPSHOT</version>
</parent>
<artifactId>common</artifactId>
<packaging>jar</packaging>
<properties>
<kotlin.version>1.3.61</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>com.test.search</groupId>
<artifactId>search-client</artifactId>
<version>[2.0,3.0)</version>
</dependency>
// 其他依赖项
</dependencies>
<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
<!--
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
-->
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
</plugins>
</reporting>
</project>
search-client POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>search-parent</artifactId>
<groupId>com.test.search</groupId>
<version>2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>search-client</artifactId>
<packaging>jar</packaging>
<name>test Search Client</name>
<dependencies>
<!-- test Search -->
<dependency>
<groupId>com.test.search</groupId>
<artifactId>search-api</artifactId>
<version>${project.parent.version}</version>
</dependency>
<!-- test -->
<dependency>
<groupId>com.test.common</groupId>
<artifactId>common-client</artifactId>
</dependency>
<!-- Languages & Frameworks -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
</dependency>
<!-- Utils -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<!-- Testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
<scope>test</scope>
</dependency>
<!-- Codecs -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
2.0-SNAPSHOT 是否不在 [2.0,3.0) 范围内?我被要求严格不增加版本号。此类Maven依赖设计下,我应
英文:
I am trying to compile a Maven project named web-server which is dependent on search-client within the specified dependency version range [2.0,3.0). The compile fails however due to a "No versions available for > com.test.search:search-client:jar:[2.0,3.0) within specified range" in the repository.
These are the steps I am following:
- Make my changes and build search-client locally
This builds a 2.0-SNAPSHOT jar for this client pom in my local m2 repository.
- Try to build web-server which is dependent on the above
This does not compile giving the following error:
> [ERROR] Failed to execute goal on project common: Could not resolve
> dependencies for project com.test.web:common:jar:2.0-SNAPSHOT: Failed
> to collect dependencies at
> com.test.search:search-client:jar:[2.0,3.0): No versions available for
> com.test.search:search-client:jar:[2.0,3.0) within specified range ->
> [Help 1]
Web Server POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>web-parent</artifactId>
<groupId>com.test.web</groupId>
<version>2.0-SNAPSHOT</version>
</parent>
<artifactId>common</artifactId>
<packaging>jar</packaging>
<properties>
<kotlin.version>1.3.61</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>com.test.search</groupId>
<artifactId>search-client</artifactId>
<version>[2.0,3.0)</version>
</dependency>
.
.
.
//Many More Dependencies
</dependencies>
<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
<!--<testSourceDirectory>src/test/kotlin</testSourceDirectory>-->
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
</plugins>
</reporting>
</project>
search-client POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>search-parent</artifactId>
<groupId>com.test.search</groupId>
<version>2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>search-client</artifactId>
<packaging>jar</packaging>
<name>test Search Client</name>
<dependencies>
<!-- test Search -->
<dependency>
<groupId>com.test.search</groupId>
<artifactId>search-api</artifactId>
<version>${project.parent.version}</version>
</dependency>
<!-- test -->
<dependency>
<groupId>com.test.common</groupId>
<artifactId>common-client</artifactId>
</dependency>
<!-- Languages & Frameworks -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
</dependency>
<!-- Utils -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<!-- Testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
<scope>test</scope>
</dependency>
<!-- Codecs -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Does 2.0-SNAPSHOT not lie in [2.0,3.0)? I have been strictly asked not to increase the version. Also, how can I go about local development in such maven dependency design?
Please help, I am stuck!
Many thanks in advance
答案1
得分: 5
根据POM参考,版本顺序规范:
> "1-snapshot
" < "1
" < "1-sp
"(资格填充)
2.0-SNAPSHOT
小于2.0
,这一直都是Maven中的情况:快照版本是下一个发布版本的预版本。
所以,2.0-SNAPSHOT
不在[2.0,3.0)
范围内(2.0 <= x < 3.0)。(1,3.0)
(1 < x < 3.0)应该可以。
而且,你的Web服务器POM中有一个拼写错误:
<version>_____3,0)</version>
英文:
According to POM Reference, Version Order Specification:
> "1-snapshot
" < "1
" < "1-sp
" (qualifier padding)
2.0-SNAPSHOT
is less than 2.0
, which always was in Maven: snapshot versions are the pre-versions of the next release version.
So, no, 2.0-SNAPSHOT
does not lie in [2.0,3.0)
(2.0 <= x < 3.0). (1,3.0)
(1 < x < 3.0) should do it.
And, there's a typo in your Web Server POM:
<version>_____3,0)</version>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论