Reputation: 51
I have created two projects using Spring Initializr: message-spring-boot-starter
and message-app
.
With the command mvn clean install
I builded the artifact of the project message-spring-boot-starter
and it appeared in the local m2 repository "com.message-starter"
Pom.xml of message-spring-boot-starter:
<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 of message-app:
<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>
I end up with an error: Could not find artifact com.message-starter:message-spring-boot-starter:jar:unknown in central (https://repo.maven.apache.org/maven2)
I want to add message-spring-boot-starter
to the dependency of message-app
project but I get this error every time.
Please tell me what I'm doing wrong and how to fix it
Upvotes: 0
Views: 861
Reputation: 5383
You need a version
tag for your dependency which specifies the version of the artifact you are trying to pull.
<dependency>
<groupId>com.message-starter</groupId>
<artifactId>message-spring-boot-starter</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
Upvotes: 3