'Cannot resolve org.springframework.cloud:spring-cloud-starter-netflix-eureka-client:unknown

I am following a tutorial to learn eureka server/client with spring boot when I try to install maven dependencies in the pom.xml I get the error in the title

this is my pom.xml file:

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.nlimits</groupId>
    <artifactId>movie_info_service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>movie_info_service</name>
    <description>Movie Info Service</description>

    <properties>
        <java.version>11</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

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

</project>

How can I solve this problem and why is it happening?



Solution 1:[1]

I too am following a tutorial as well.

I created a basic microservice using Spring Boot in IntelliJ 2020.1

I added the spring-cloud-starter-netflix-eureka-client starter to my project.

Here is what was added to the pom.xml:

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>

 <dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-dependencies</artifactId>
  <version>Hoxton.SR8</version>
  <type>pom</type>
  <scope>import</scope>
</dependency>

After reloading the maven pom.xml file, I get the error that dependency is not found.

Here is the error:

Cannot resolve org.springframework.cloud:spring-cloud-starter-netflix-eureka-client:unknown

I am using Spring Boot 2.3.5.

<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.5.RELEASE</version>

SOLUTION :

For some reason, the version of the eureka discovery client is not added automatically to the pom when using the spring initializr to add the spring-boot-starter. So I added the version manually:

<version>2.2.5.RELEASE</version>
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
  <version>2.2.5.RELEASE</version>
</dependency>

Then after refreshing the maven pom.xml the dependency was recognized.

Solution 2:[2]

just add this code after <dependencies/> section and before <build/> section:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-parent</artifactId>
            <version>Greenwich.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Solution 3:[3]

I managed to solve this problem by adding spring cloud version in properties.

<properties>
    <java.version>11</java.version>
    <spring-cloud.version>Hoxton.SR8</spring-cloud.version>
</properties>

Solution 4:[4]

Check the Spring boot Starter version (2.3.3) and Spring Cloud version (2.2.5), it fails your build, I recommend to use Spring Initializer to create your pom/build file for your project.

Solution 5:[5]

I realized the jar files are downloaded into "Maven Dependencies" in the project folder but the POM error still exist.

Solution:- Delete the C:\Users<user>.m2 folder and then reload maven from POM.

Solution 6:[6]

Change the spring boot version (and the spring cloud version) in the pom.xml

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.5.RELEASE</version>
    <relativePath/> 
</parent>

<properties>
    <java.version>11</java.version>
    <spring-cloud.version>Greenwich.SR1</spring-cloud.version>
</properties>

Solution 7:[7]

At Spring Start, when creating the project, also take the repositories, these guys are fundamental.

<repositories>
      // DATA
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      // DATA
    </pluginRepository>
    <pluginRepository>
      // DATA
    </pluginRepository>
  </pluginRepositories>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ℛɑƒæĿᴿᴹᴿ
Solution 2 Co ti
Solution 3 Jakov
Solution 4 Abrar Ansari
Solution 5 Mathan
Solution 6 nakiDevI
Solution 7