javaspring-bootnetflix-eureka

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

  • 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.