我已经使用Spring Initializr创建了两个项目:message-spring-boot-starter
和message-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
项目的依赖项中,但每次都出现此错误。
请告诉我我做错了什么,如何改正
1条答案
按热度按时间snvhrwxg1#
依赖项需要一个
version
标记,用于指定要提取的工件的版本。