I‘.’对不起,如果我不懂某些单词的话.
我一直有错误:无法解析符号@EnableEurekaServer.当我手动输入eureka服务器的导入行时,"cloud“一词被突出显示为红色:
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;在我的build.gradle文件中
compile('org.springframework.cloud:spring-cloud-netflix-eureka-server')为什么会发生这种事。一切看起来都正常。我可以提供截图的东西,如果有人问!
我的build.gradle文件如下所示:
buildscript {
ext {
springBootVersion = '2.0.0.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.cloud:spring-cloud-netflix-eureka-server')
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
}我的EurekaApplicationServer.java看起来是这样的:
package com.example.eurekaserver;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
//import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
public class EurekaApplicationServer {
public static void main(String[] args) {
SpringApplication.run(EurekaApplicationServer.class, args);
}
}发布于 2018-09-30 08:42:18
没有必要降低eureka服务器/客户端的版本。原因是maven repo无法解决eureka server.To的最新版本,请将存储库添加到pom/gradle文件中。
repositories {
maven {
url 'https://repo.spring.io/libs-milestone'
}
}或
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
https://stackoverflow.com/questions/49328567
复制相似问题