Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EnableEurekaClient import doesn't exist

I added spring-cloud-starter-netflix-eureka-client gradle depedency in my project and shrik the depedency. But when go use @EnableEurekaClient in my Main class it show me suggestion create @EnableEurekaClient annotation. Don't show any import file of eureka client.

Unresolved reference: EnableEurekaClient

productserviceApplication.kt

  package com.main.productservice
    
    import org.springframework.boot.autoconfigure.SpringBootApplication
    import org.springframework.boot.runApplication
    
    @SpringBootApplication
    @EnableEurekaClient
    class ProductServiceApplication
    
    fun main(args: Array<String>) {
        runApplication<ProductServiceApplication>(*args)
    }

gradle.kt

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    id("org.springframework.boot") version "2.5.2"
    id("io.spring.dependency-management") version "1.0.11.RELEASE"
    kotlin("jvm") version "1.5.20"
    kotlin("plugin.spring") version "1.5.20"
}

group = "com.main"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_11

repositories {
    mavenCentral()
}

dependencies {
    implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
    implementation("org.springframework.boot:spring-boot-starter-web")
    implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
    implementation("org.jetbrains.

    kotlin:kotlin-reflect")
        implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
        implementation("org.springframework.cloud:spring-cloud-starter-netflix-eureka-client")
        testImplementation("org.springframework.boot:spring-boot-starter-test")
    }
    
    tasks.withType<KotlinCompile> {
        kotlinOptions {
            freeCompilerArgs = listOf("-Xjsr305=strict")
            jvmTarget = "11"
        }
    }
    
    tasks.withType<Test> {
        useJUnitPlatform()
    }

I am getting error at @EnableEurekaClient

like image 495
Mama Avatar asked Dec 20 '25 17:12

Mama


1 Answers

@EnableEurekaClient is deprecated, no need to annotate the main class. It is enough to add the spring-cloud-starter-netflix-eureka-client dependency to pom.xml and if we have the application name in yml or properties file it will be registered to Eureka Server.

like image 125
Saipriyadarshini Bandi Avatar answered Dec 22 '25 17:12

Saipriyadarshini Bandi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!