Eureka服务器错误EurekaClientAutoConfiguration

时间:2018-06-12 12:27:31

标签: spring-boot netflix-eureka

创建名为'org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration'的bean时出错:通过构造函数参数0表示不满意的依赖关系;嵌套异常是org.springframework.beans.factory.NoSuchBeanDefinitionException:没有类型为'org.springframework.core.env.ConfigurableEnvironment'的限定bean可用:预计至少有一个bean可以作为autowire候选者。

Eureka error screenshot

  

的build.gradle

buildscript {
    ext {
        springBootVersion = '2.0.2.RELEASE'
        springCloudVersion = 'Finchley.RC2'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'com.ragavan'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
    maven { url "https://repo.spring.io/milestone" }
}

configurations {
    providedRuntime
}

dependencies {
    compile('org.springframework.boot:spring-boot-starter-actuator')
    compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-server')
    runtime('org.springframework.boot:spring-boot-devtools')
    providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}
  

应用

package com.ragavan.discovery;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@SpringBootApplication
@EnableEurekaServer
public class DiscoveryServerApplication {

  public static void main(String[] args) {
    SpringApplication.run(DiscoveryServerApplication.class, args);
  }
}

2 个答案:

答案 0 :(得分:1)

我也面临着同样的问题: “没有类型为'org.springframework.core.env.ConfigurableEnvironment'的合格Bean'”

我在春季启动项目中使用了STS + maven,因此使用“使用快照版本强制更新”更新项目将解决此问题。

update dependencies

还要检查端口是否尚未使用

在application.properties中

spring.application.name=server
server.port=8761

服务器将在如下所示的端口上启动:

Server started screenshot

答案 1 :(得分:0)

2.1.4.RELEASE也有相同的问题。但它以2.1.5.RELEASE解决。