当前位置: 首页 > 知识库问答 >
问题:

将Spring Boot parent starter从1.5升级到2.1.1

宇文鸿振
2023-03-14
Exception in thread "main" java.lang.AbstractMethodError: org.springframework.boot.context.config.ConfigFileApplicationListener.supportsSourceType(Ljava/lang/Class;)Z
    at org.springframework.context.event.GenericApplicationListenerAdapter.supportsSourceType(GenericApplicationListenerAdapter.java:79)
    at org.springframework.context.event.AbstractApplicationEventMulticaster.supportsEvent(AbstractApplicationEventMulticaster.java:289)
    at org.springframework.context.event.AbstractApplicationEventMulticaster.retrieveApplicationListeners(AbstractApplicationEventMulticaster.java:221)
    at org.springframework.context.event.AbstractApplicationEventMulticaster.getApplicationListeners(AbstractApplicationEventMulticaster.java:192)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
    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.schedule.ScheduleServiceApplication.main(ScheduleServiceApplication.java:58)
2018-12-18 12:31:58,999 INFO  [  ] --- [background-preinit] o.h.v.i.u.Version - HV000001: Hibernate Validator 6.0.13.Final
2018-12-18 12:31:59,851 ERROR [  ] --- [main] o.s.b.SpringApplication - Application run failed
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(TServiceApplication.java:34)

pom.xml

与Spring Boot starter父级相关的最新升级版本

<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>

    <dependencies>

        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <version>6.2.0.jre8</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jersey</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>


        <dependency>
            <groupId>org.jmockit</groupId>
            <artifactId>jmockit</artifactId>
            <version>1.30</version>
            <scope>test</scope>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>2.1.1.RELEASE</version> 
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>${springfox.version}</version>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>${springfox.version}</version>
        </dependency>


        <!-- <dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    </dependency> 
 -->
        <dependency>
            <groupId>org.jmockit</groupId>
            <artifactId>jmockit</artifactId>
            <version>1.30</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.2</version>
        </dependency>
        <!-- Registry & Discovery -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>

        <!-- For Config Server -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>

        <dependency>
            <groupId>com.nimbusds</groupId>
            <artifactId>nimbus-jose-jwt</artifactId>
            <version>4.34.1</version>
        </dependency>
    <dependency>

            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
              <version>20160212</version>
        </dependency>
        <!-- <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
       <version>3.8.0</version>

         </dependency> -->
        <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>io.lettuce</groupId>
            <artifactId>lettuce-core</artifactId>
            </dependency>
        <dependency>
            <groupId>biz.paluch.redis</groupId>
            <artifactId>lettuce</artifactId>
            <version>4.4.1.Final</version>
        </dependency>

    </dependencies>

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


        </dependencies>
    </dependencyManagement>

    <build>
        <finalName>titles</finalName>
        <plugins>

 <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
     <source>1.8</source>
     <target>1.8</target>
    </configuration>
   </plugin>  


            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.7.8</version>
                <configuration>

                </configuration>
                <executions>
                    <execution>
                        <id>default-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-check</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <!-- implementation is needed only for Maven 2 -->
                                <rule implementation="org.jacoco.maven.RuleConfiguration">
                                    <element>BUNDLE</element>
                                    <limits>
                                        <!-- implementation is needed only for Maven 2 -->
                                        <limit implementation="org.jacoco.report.check.Limit">
                                            <counter>LINE</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.00</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.5</version>
                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                        <configuration>
                            <groupId>com.junit.junit-tools</groupId>
                            <artifactId>junit-tools</artifactId>
                            <version>1.0</version>
                            <packaging>jar</packaging>
                            <file>D:/.../test9/titles/Junit-Jar/Junit-Jar/junit-tools.jar</file>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.5</version>
                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                        <configuration>
                            <groupId>com.junit.jmockit</groupId>
                            <artifactId>jmockit</artifactId>
                            <version>1.0</version>
                            <packaging>jar</packaging>
                            <file>D:/.../test9/titles/Junit-Jar/Junit-Jar/jmockit.jar</file>
                        </configuration>
                    </execution>
                </executions>
            </plugin>  -->


        </plugins>
    </build>

    <reporting>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.19.1</version>
            </plugin>
        </plugins>
    </reporting>


</project>

共有1个答案

尹昂雄
2023-03-14

您使用的是Spring CloudBrixton,这是一个非常古老的EOL,即使对于Spring Boot也是如此。您不能只升级Spring Boot而不查看构建文件中的其他版本,因为这些版本必须保持同步。

Spring Boot在很大程度上帮助您对许多依赖项进行精心策划的依赖项管理。不幸的是,对于构建在Spring Boot之上的组件(Spring Cloud就是其中之一),它无法做到这一点。

文档提供了兼容的版本。在撰写本文时,Greenwich甚至还不是GA。您还可以在https://start.spring.io/上使用CALL依赖项引导项目,以查看推荐的构建。

 类似资料:
  • 我一直在寻找flyway版本1中的迁移方法。x到3。x(即从Google.com.googlecode.flyway到org.flywaydb)在提到要首先迁移到2.3版的地方,但没有提到如何迁移?有没有一种直接的方法可以做到这一点,或者我必须从后端做一些事情。 我的数据库已经有数据,我不能删除数据库。注意:Flyway 1. X到2. X对table有重大更改。 编辑 我已经将flyway的ma

  • 我正在将我的django项目从1.8升级到2.2.0(使用virtualenv中的Python 3.6)。我做了以下更改。 将on_delete添加到所有外键字段 将url反向导入更改为来自django。URL反向导入 在所有应用程序的url文件中包含路径/re_path而不是url 将设置文件中的MIDDLEWARE_CLASSES导入更改为MIDDLEWARE={} 我试图运行服务器,但它仍然

  • 我面临的问题与更新facebook SDK从4.7到4.35 实现'com。脸谱网。android:facebook android sdk:4.35.0' 错误输出为 无法复制C:\用户\泰\下载\项目\karufx-android-更新\app\构建\中间体\转换\desugar\调试\138.jar备份文件夹,构建将继续,但下次修改此文件时将导致冷交换。 和 意外输入:ImmutableJa

  • 1.5 Kali更新与升级 当用户使用一段时间以后,可能对总是在没有任何变化的系统中工作感到不满,而是渴望能像在Windows系统中一样,不断对自己的Linux进行升级。另外,Linux本身就是一个开放的系统,每天都会有新的软件出现,Linux发行套件和内核也在不断更新。在这样的情况下,学会对Linux进行升级就显得非常迫切了。本节将介绍Kali的更新与升级。 更新与升级Kali的具体操作步骤如下

  • 我需要知道如何将我的Weblogic应用程序服务器从版本1升级到版本2。我的操作系统是Windows 7 64位。我是新来的,其他人安装了weblogic,所以我试图自己安装它,但它给我错误 C: \用户\用户\下载 所以我用7个拉链拉开了罐子的拉链,现在插入器已经开始了,这是正确的方法吗?

  • 为了帮助大伙儿升级,我们为现在的Apache用户提供了一份重要信息的文档说明。这些只是一些简要说明,你可以从新特性文档或src/CHANGES文件中得到更多信息。 这篇文档仅仅描述了从版本 2.0 到 2.2 的变化,如果你是从1.3版进行升级的,请查考从1.3升级到2.0文档。 编译时配置的改变 编译过程与2.0版本非常相似,你曾经使用过的configure命令行(在安装目录下的build/co