Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 无法解析intelliJ中EnableEurekaServer的符号。是的,我的依赖项/无效+;重新启动(我的IDE)_Spring_Gradle_Intellij Idea_Netflix Eureka - Fatal编程技术网

Spring 无法解析intelliJ中EnableEurekaServer的符号。是的,我的依赖项/无效+;重新启动(我的IDE)

Spring 无法解析intelliJ中EnableEurekaServer的符号。是的,我的依赖项/无效+;重新启动(我的IDE),spring,gradle,intellij-idea,netflix-eureka,Spring,Gradle,Intellij Idea,Netflix Eureka,我是一个Java初学者,如果我不懂某些单词,请提前道歉 我一直有一个错误:无法解析符号@EnableEurekaServer。。。当我手动输入eureka服务器的导入行时,“云”一词在以下位置以红色突出显示: import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 在build.gradle文件中,我有 compile('org.springframework.cloud:spring-cloud-n

我是一个Java初学者,如果我不懂某些单词,请提前道歉

我一直有一个错误:无法解析符号@EnableEurekaServer。。。当我手动输入eureka服务器的导入行时,“云”一词在以下位置以红色突出显示:

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')
}
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);
    }

}
我的EurekaApplicationServer.java如下所示:

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')
}
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);
    }

}

使用特定版本的依赖关系,撰写本文时的当前版本为:

compile('org.springframework.cloud:spring-cloud-netflix-eureka-server:1.4.3.RELEASE')
您可以找到最新的可用版本号


对于Spring引导项目,如果不指定依赖项版本,则使用特殊插件。出于某种原因,它无法提供此特定依赖项的版本。请参阅。

无需降低eureka服务器/客户端的版本。 原因是maven repo无法解析最新版本的eureka服务器。若要解决此问题,请将存储库添加到pom/gradle文件中

repositories {
    maven {
        url 'https://repo.spring.io/libs-milestone'
    }
}


春季里程碑
春季里程碑
https://repo.spring.io/libs-milestone
假的


org.springframework.cloud
spring云netflix eureka服务器
1.1.6.1发布

这对我很有用。

请分享。我想我添加了足够的信息。将依赖项更改为
compile('org.springframework.cloud:spring-cloud-netflix-eureka-server:1.0.0.RELEASE')
为我解决了这个问题。好吧。。。成功了。天哪。非常感谢你,伙计。这也是一个如此简单的解决方案。但它这样做有什么原因吗?我想知道为什么事情会出错。啊,我明白了,我明白了!谢谢你的解释。您是否介意查看此图像,看看您是否能找出我出现此错误的原因: