java Pom.xml无法从m2本地资料档案库中找到工件

hc2pp10m  于 2022-11-27  发布在  Java
关注(0)|答案(1)|浏览(181)

我已经使用Spring Initializr创建了两个项目:message-spring-boot-startermessage-app中的一个或多个。
使用命令mvn clean install,我构建了项目message-spring-boot-starter的工件,它出现在本地m2资源库“com.message-starter”中。
message-spring-boot-starter的Pom.xml文件:

<modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.message-starter</groupId>
    <artifactId>message-spring-boot-starter</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>message-spring-boot-starter</name>
    <description>message-spring-boot-starter</description>
    <properties>
        <java.version>11</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

消息应用程序的Pom.xml:

<modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>message-app</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>message-app</name>
    <description>message-app</description>
    <properties>
        <java.version>11</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.message-starter</groupId>
            <artifactId>message-spring-boot-starter</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

最后出现一个错误:Could not find artifact com.message-starter:message-spring-boot-starter:jar:unknown in central (https://repo.maven.apache.org/maven2)
我想将message-spring-boot-starter添加到message-app项目的依赖项中,但每次都出现此错误。
请告诉我我做错了什么,如何改正

snvhrwxg

snvhrwxg1#

依赖项需要一个version标记,用于指定要提取的工件的版本。

<dependency>
            <groupId>com.message-starter</groupId>
            <artifactId>message-spring-boot-starter</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>

相关问题