JDK 17 Spring Boot: 2.6.4 Spring Cloud: 2021.0.1

Eureka server is up and running and I can see the Eureka Dashboard on localhost:8000 which is configured in my application.yml

But, when configuring the client, the application doesn't start at all, with below stack trace:

Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.boot.BootstrapRegistryInitializer : org.springframework.cloud.netflix.eureka.config.EurekaConfigServerBootstrapper
    at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:456)
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:438)
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:431)
    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:261)
    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:241)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)
    at com.cryptified.exchange.coin.bitcoin.BitcoinApplication.main(BitcoinApplication.java:18)
Caused by: java.lang.NoClassDefFoundError: com/netflix/discovery/shared/resolver/EurekaEndpoint
    at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3373)
    at java.base/java.lang.Class.getConstructor0(Class.java:3578)
    at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2754)
    at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:451)
    ... 7 more
Caused by: java.lang.ClassNotFoundException: com.netflix.discovery.shared.resolver.EurekaEndpoint
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    ... 12 more

Process finished with exit code 1

However, the application was up and running in Spring boot version 2.0.5. Just started the upgrade process for better performance.

Here's my client main method code:

@SpringBootApplication
@EnableEurekaClient
@ComponentScan(basePackages = {"com.cryptified.exchange.coin.bitcoin", "com.cryptified.core.app"})
@EnableFeignClients(basePackages = {"com.cryptified.core.app.gateway.coinGateway", "com.cryptified.exchange.coin.bitcoin"})
@EnableAsync
public class BitcoinApplication {

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

Here's client application.yml config:

eureka:
  client:
    serviceUrl:
      defaultZone: ${EUREKA_URI:http://localhost:8000/eureka}
  instance:
    preferIpAddress: true

hystrix:
  command:
    default:
      execution:
        timeout:
          enabled: false
        isolation:
          strategy: THREAD
          thread:
            timeoutInMilliseconds: 12000
ribbon:
  eureka:
    enabled: true
  MaxAutoRetries: 0
  MaxAutoRetriesNextServer: 0
  ConnectTimeout: 120000
  ReadTimeout: 120000
  OkToRetryOnAllOperations: false

Client Pom.xml

    <dependencies>
        <dependency>
            <groupId>com.cryptified</groupId>
            <artifactId>app-core</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.cryptified</groupId>
            <artifactId>mysql-core</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-netflix-eureka-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

Comment From: kunalbarchha

Please close this. the issue was in the pom.xml. had to use spring-cloud-starter-netflix-eureka-client.