SpringCloud异常(Euruka):Application run failed java.lang.NoSuchMethodError: org.springframework.boot

问题:SpringCloud异常(Euruka):java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.([Ljava/lang/Object;)V


<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.0modelVersion>

    <groupId>com.samplegroupId>
    <artifactId>microservice-discovery-eureka1artifactId>
    <version>1.0-SNAPSHOTversion>
    <packaging>jarpackaging>

    <name>microservice-discovery-eurekaname>
    <description>Demo project for Spring Bootdescription>
    
    <parent>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-parentartifactId>
        <version>2.0.3.RELEASEversion>
        <relativePath/> 
    parent>

    <properties>
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
        <java.version>1.8java.version>
    properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-webartifactId>
       dependency>
        <dependency>
            <groupId>org.springframework.cloudgroupId>
            <artifactId>spring-cloud-starter-eureka-serverartifactId>
            <version>1.4.3.RELEASEversion>
        dependency>
    dependencies>


    
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloudgroupId>
                <artifactId>spring-cloud-dependenciesartifactId>
                <version>Finchleyversion>
                <type>pomtype>
                <scope>importscope>
            dependency>
        dependencies>

    dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-maven-pluginartifactId>
            plugin>
        plugins>
    build>
project>

分析: SpringBoot、SpringCloud和Eureka版本不兼容所致

Eureka版本为:1.4.3

        <dependency>
            <groupId>org.springframework.cloudgroupId>
            <artifactId>spring-cloud-starter-eureka-serverartifactId>
            <version>1.4.3.RELEASEversion>
        dependency>

SpringBoot版本为2.0.3,更改为1.5.13

    <parent>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-parentartifactId>
        <version>2.0.3.RELEASEversion>
        <relativePath/> 
    parent>

SpringCloud版本为Finchley,更改为Edgware.SR3

     <dependencies>
            <dependency>
                <groupId>org.springframework.cloudgroupId>
                <artifactId>spring-cloud-dependenciesartifactId>
                <version>Finchleyversion>
                <type>pomtype>
                <scope>importscope>
            dependency>
        dependencies>

重新import包,SpringBootApplication即可成功启动。

你可能感兴趣的:(java)