0

I am trying to create a spring cloud eureka server with spring boot initialize.

But I am getting the below exception.

java.lang.IllegalStateException: Failed to load ApplicationContext Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration': Unsatisfied dependency expressed through field 'optionalArgs'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'discoveryClientOptionalArgs' defined in class path resource [org/springframework/cloud/netflix/eureka/config /DiscoveryClientOptionalArgsConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.netflix.discovery.AbstractDiscoveryClientOptionalArgs] from ClassLoader [sun.misc.Launcher$AppClassLoader@6bc7c054] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'discoveryClientOptionalArgs' defined in class path resource [org/springframework/cloud/netflix/eureka/config /DiscoveryClientOptionalArgsConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.netflix.discovery.AbstractDiscoveryClientOptionalArgs] from ClassLoader [sun.misc.Launcher$AppClassLoader@6bc7c054] Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.netflix.discovery.AbstractDiscoveryClientOptionalArgs] from ClassLoader [sun.misc.Launcher$AppClassLoader@6bc7c054] Caused by: java.lang.NoClassDefFoundError: com/netflix/eventbus/spi/EventBus Caused by: java.lang.ClassNotFoundException: com.netflix.eventbus.spi.EventBus

This is my config file:

ymlfiles

server:
  port: 8761
eureka:
  client:
    registerWithEureka: false
    fetchRegistry: false

And this is my pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.eureka.server</groupId>
    <artifactId>spring-eureka-server</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>spring-eureka-server</name>
    <description>Spring Eureka Server</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.1.RELEASE</version>
        <relativePath/>
        <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Finchley.RC1</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        </dependency>

        <!-- <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-eureka-server</artifactId>
        <version>1.1.5.RELEASE</version>
        </dependency> -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

</project>
Cœur
  • 37,241
  • 25
  • 195
  • 267
Prakash
  • 1
  • 1
  • 3

2 Answers2

2

I faced this error too (Spring Boot 2.0.3.RELEASE). Solved it by deleting local maven repositories and mvn clean, mvn package, reimport in idea. Spooky issue.

0

I have deleted .m2 folder several times. This issue occurs anytime.

Following is my fix...

I have chaged the spring cloud version from following... <spring-cloud.version>Hoxton.SR11</spring-cloud.version> to <spring-cloud.version>Greenwich.SR1</spring-cloud.version>

ERROR gone!

NCG
  • 57
  • 1
  • 9