首页 > 解决方案 > AbstractMethodError org.springframework.boot.context.config.ConfigFileApplicationListener.supportsSourceType with Spring boot 2.2.1

问题描述

我正在尝试使用 Spring Boot Starter 2.2.1、Spring Cloud 版本 Hoxton 和 Cloud Stream 版本 3.0.0 设置一个 Spring Cloud Stream 项目。

下面是我的 pom.xml

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.1.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
    <spring-cloud.version>Hoxton.RELEASE</spring-cloud.version>

    <java.version>1.8</java.version>
    <kotlin.version>1.3.61</kotlin.version>
    </properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>5.2.1.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>jcl-over-slf4j</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-actuator</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
        </exclusions>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-messaging</artifactId>
    </dependency>

</dependencies>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

当我运行应用程序时,我看到

java.lang.AbstractMethodError: org.springframework.boot.context.config.ConfigFileApplicationListener.supportsSourceType(Ljava/lang/Class;)Z at org.springframework.context.event.GenericApplicationListenerAdapter.supportsSourceType(GenericApplicationListenerAdapter.java:81)
   ...

我发现从 spring boot 2.0.5 迁移到 2.1.1 并且由于依赖项不匹配会引发相同的错误。

就我而言,我相信我使用的是正确的 Spring boot 和Spring Cloud发布版本,这pom.xml是由 spring initializr 生成的。

但是,我尝试将 spring-core 升级到 5.2.1.release,因为默认的 spring-core(版本 5.0.5)抛出了这个错误 =>Caused by: java.lang.ClassNotFoundException: org.springframework.util.unit.DataSize并且这个类是在 5.2.1 中引入的。

有人在 Spring boot 2.2.1 中遇到过这个错误吗?任何输入都受到高度赞赏。谢谢。

标签: spring-bootspring-cloudspring-cloud-stream

解决方案


推荐阅读