Search code examples
javaspring-bootspring-cloudspring-batch-admin

Could not start springboot-admin:java.lang.NoClassDefFoundError: org/springframework/cloud/netflix/zuul/ZuulServerAutoConfiguration


when i try to start springboot-admin,it throw : java.lang.NoClassDefFoundError: org/springframework/cloud/netflix/zuul/ZuulServerAutoConfiguration Is it my version conflict?

SpringBoot version:2.1.9.RELEASE

SpringCloud version:Greenwich.SR3

SpringBootAdmin version:2.1.5

my main class code:

@Configuration
@EnableAutoConfiguration
@EnableAdminServer
@EnableDiscoveryClient
public class SpringbootAdminApplication {

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

}

my maven code:

 <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.9.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
<!-- It's partly dependent-->
<dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-server</artifactId>
            <version>2.1.5</version>
        </dependency>
 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
 <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Greenwich.SR3</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

my configure file :

spring:
  application:
    name: spring-boot-admin
eureka:
  client:
    service-url:
      defaultZone: http://localhost:8010/eureka
server:
  port: 8083

I want to start the application


Solution

  • Move your spring-cloud dependencies under dependencyManagement tag, and try,

    <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-dependencies</artifactId>
                    <version>Greenwich.SR3</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>