'EnableEurekaServer import doesn't exist

I build a Spring-Service with gradle and I wanted to use a Eureka-Server with it. My java-file looks like this:

import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@EnableEurekaServer
public class Welcome {
   ....
}

but when I try to build it with my gradle-file it says:

org.springframework.cloud.netflix.eureka.server does not exist

I searched for a solution for this problem but I seem to be alone with it. Does someone know why it is not working? Do I have to write something specific into the build.gradle-file?



Solution 1:[1]

The following dependency worked for me:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-netflix-eureka-server</artifactId>
    <version>1.1.6.RELEASE</version>
</dependency>

Solution 2:[2]

Assuming you use a bill of materials to manage Spring Cloud dependencies:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Just add the following depedency to your project:

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

Spring Cloud releases have names instead of numbers. And you must ensure that Spring Cloud version is compatible with the Spring Boot version you are using. See more details here.

Solution 3:[3]

Well if you are using gradle project, just add below dependency to your build.gradle file:

compile('org.springframework.cloud:spring-cloud-netflix-eureka-server')

Solution 4:[4]

Specify repository in pom if missing:

<repositories>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

Solution 5:[5]

Make sure that you havespring-cloud-starter-netflix-eureka-server added in your pom.xml file

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

Solution 6:[6]

Adding this dependency worked for me.

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-netflix-eureka-server</artifactId>
    <version>3.1.2</version>
</dependency>

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 vdimitrov
Solution 2 cassiomolin
Solution 3 Aditi Rawat
Solution 4 Eagle_Eye
Solution 5 T. Huebart
Solution 6 Prashant