EnableEurekaClient 导入不存在
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
确保在您的 Gradle 构建定义中导入 Spring Cloud BOM:
extra["springCloudVersion"] = "2020.0.3"
dependencyManagement {
imports {
mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}")
}
}
EnableEurekaClient 注释在包 org.springframework.cloud.netflix.eureka
中。您应该将以下导入添加到您的主应用程序文件中:
import org.springframework.cloud.netflix.eureka.EnableEurekaClient
@EnableEurekaClient 已弃用 无需在 spring 启动主应用程序时注释 如果我们在 pom 中添加 spring-cloud-starter-netflix-eureka-client 依赖项并且如果我们有yml 或 properties 文件中的应用程序名称它将被注册到 Eureka Server
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
确保在您的 Gradle 构建定义中导入 Spring Cloud BOM:
extra["springCloudVersion"] = "2020.0.3"
dependencyManagement {
imports {
mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}")
}
}
EnableEurekaClient 注释在包 org.springframework.cloud.netflix.eureka
中。您应该将以下导入添加到您的主应用程序文件中:
import org.springframework.cloud.netflix.eureka.EnableEurekaClient
@EnableEurekaClient 已弃用 无需在 spring 启动主应用程序时注释 如果我们在 pom 中添加 spring-cloud-starter-netflix-eureka-client 依赖项并且如果我们有yml 或 properties 文件中的应用程序名称它将被注册到 Eureka Server