Spring Boot升级到最新版本

时间:2018-12-18 17:50:13

标签: java spring spring-boot spring-cloud

在升级springBoot启动器父代2.1.1。发行版时获得以下异常。

java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:120)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:84)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:62)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:347)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
    at com.nbcuni.compass.title.TServiceApplication.main(TitleServiceApplication.java:34)

POM.xml

PFB,pom.xml,具有完整的父2.1.1。发行和依赖性管理,作为Brixton.SR5版本的详细信息

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.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.9</java.version>
        <springfox.version>2.6.0</springfox.version>
    </properties>
<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Brixton.SR5</version>
                <!-- <version>Brixton.SR5</version> -->
                <type>pom</type>
                <scope>import</scope>
            </dependency>
                    </dependencies>
    </dependencyManagement>

2 个答案:

答案 0 :(得分:3)

Brixton.SR5from 2016,并且自发布之初in 2018不支持Spring Boot 2。如果它适用于2.1.1以下的Spring Boot版本,那是偶然的。

您需要将Spring Cloud升级到最新版本,例如Finchley SR2

答案 1 :(得分:1)

  

Brixton建立在Spring Boot 1.3.x之上

     

Finchley构建并与Spring Boot 2.0.x一起使用,这是不期望的   与Spring Boot 1.5.x一起使用。

用Finchley替换Brixton。在pom中添加以下依赖项:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-dependencies</artifactId>
    <version>Finchley.RELEASE</version>
    <type>pom</type>
</dependency>

Follow this link for details.