将Spring Boot 1.5.10迁移到2.0.6时出错

时间:2018-10-22 15:36:31

标签: spring spring-boot

我正在尝试将Spring Boot应用程序从Spring Boot版本1.5.10迁移到2.0.6。我的应用程序在Spring Boot 1.5.10上运行良好。但是,当我将其更改为2.0.6时,无法启动我的应用程序。我得到了例外。

Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.boot.SpringApplication.run(Ljava/lang/Object;[Ljava/lang/String;)Lorg/springframework/context/ConfigurableApplicationContext;
    at com.trng.pcf02.Pcf02Application.main(Pcf02Application.java:15)

我正在使用Gradle 4.5和Intellij IDEA作为我的IDE。

这是我的gradle文件

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

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

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

repositories {
    mavenCentral()
}


ext {
    springCloudServicesVersion = '2.0.1.RELEASE'
    springCloudVersion = 'Finchley.SR1'
}

dependencies {
    implementation('io.pivotal.spring.cloud:spring-cloud-services-starter-service-registry')
    compile('org.springframework.boot:spring-boot-starter')
    compile("org.springframework.boot:spring-boot-starter-web")
    testImplementation('org.springframework.boot:spring-boot-starter-test')
}

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

我的主修课如下

@EnableDiscoveryClient
@SpringBootApplication
public class Pcf02Application {

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

任何帮助将不胜感激。

0 个答案:

没有答案