Maven-无法在本地解决版本范围的Maven依赖关系

质子复兴:

我正在尝试编译一个名为web-server的Maven项目,该项目在指定的依赖项版本范围[2.0,3.0)中依赖于search-client但是,由于存储库中出现“指定范围内没有适用于com.test.search:search-client:jar:[2.0,3.0)的版本”,因此编译失败。

这些是我要执行的步骤:

  1. 进行更改并在本地构建搜索客户端

这将在我的本地m2存储库中为此客户端pom构建一个2.0-SNAPSHOT jar。

  1. 尝试构建依赖于上述内容的Web服务器

这不会编译,并出现以下错误:

[错误]无法在公共项目上执行目标:无法解析项目com.test.web:common:jar:2.0-SNAPSHOT的依赖项:无法在com.test.search:search-client:jar:[2.0]上收集依赖项,3.0):指定范围内com.test.search:search-client:jar:[2.0,3.0)没有可用的版本-> [帮助1]

Web服务器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>

搜索客户端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依赖设计中进行本地开发?

请帮助,我被卡住了!

提前谢谢了 :)

Gerold Broser:

根据POM参考,版本顺序规范

1-snapshot” <“ 1” < 1-sp“(限定符填充)

2.0-SNAPSHOT2.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>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章