首頁  >  文章  >  正確的應用程式類別路徑,使其包含 org.springframework.beans.factory.config.ConfigurableListableBeanFactory 的單一相容版本

正確的應用程式類別路徑,使其包含 org.springframework.beans.factory.config.ConfigurableListableBeanFactory 的單一相容版本

王林
王林轉載
2024-02-05 22:24:031010瀏覽
問題內容

我收到以下錯誤 應用程式無法啟動

描述:

嘗試呼叫不存在的方法。嘗試從以下位置進行:

org.springframework.boot.actuate.autoconfigure.startup.startupendpointautoconfiguration$applicationstartupcondition.getmatchoutcome(startupendpointautoconfiguration.java:63)

以下方法不存在:

org.springframework.beans.factory.config.configurablelistablebeanfactory.getapplicationstartup()lorg/springframework/core/metrics/applicationstartup;

該方法的類別 org.springframework.beans.factory.config.configurablelistablebeanfactory 可從下列位置取得: jar:文件:/users/doc/.m2/repository/org/springframework/spring-beans/5.2.5.release/spring-beans-5.2.5.release.jar! /org/springframework/beans/factory/config /configurablelistablebeanfactory.class

它是從以下位置載入的:

file:/users/doc/.m2/repository/org/springframework/spring-beans/5.2.5.release/spring-beans-5.2.5.release.jar

行動:

修正應用程式的類別路徑,使其包含單一相容版本的 org.springframework.beans.factory.config.configurablelistablebeanfactory

pom

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.6.RELEASE</version>

</parent>



<properties>
    <java.version>1.8</java.version>
 

   
    <!-- Spring Dependencies -->
    <spring-retry.version>1.3.1</spring-retry.version>
    <spring-cloud-netflix-core.version>1.1.7.RELEASE</spring-cloud-netflix-core.version>
    <spring-cloud-vault-config.version>3.1.1</spring-cloud-vault-config.version>
    <spring-vault-core.version>2.3.2</spring-vault-core.version>
 



    <!-- Swagger Dependencies -->
    <springfox-swagger2.version>2.4.0</springfox-swagger2.version>

   
</properties>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.retry</groupId>
            <artifactId>spring-retry</artifactId>
            <version>${spring-retry.version}</version>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-netflix-core</artifactId>
            <version>${spring-cloud-netflix-core.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-vault-config</artifactId>
            <version>${spring-cloud-vault-config.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.vault</groupId>
            <artifactId>spring-vault-core</artifactId>
            <version>${spring-vault-core.version}</version>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Hoxton.SR6</version>
        </dependency>
       
        
       
        <!-- Swagger Dependencies-->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>${springfox-swagger2.version}</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>${springfox-swagger2.version}</version>
        </dependency>
        <!-- Testing dependencies -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-staticdocs</artifactId>
            <version>${springfox-swagger2.version}</version>
        </dependency>
    </dependencies>
</dependencyManagement>
<dependencies>
  
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-vault-config</artifactId>
        <version>${spring-cloud-vault-config.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.vault</groupId>
        <artifactId>spring-vault-core</artifactId>
        <version>${spring-vault-core.version}</version>
    </dependency>
    
   
    <!-- Spring dependencies -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-actuator-autoconfigure</artifactId>
        <version>2.4.0</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.25</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.retry</groupId>
        <artifactId>spring-retry</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-openfeign</artifactId>
        <version>2.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
        <version>2.1.0.RELEASE</version>
    </dependency>

正確答案


您正試圖超越 spring boot 和 spring cloud 依賴管理,並包含大量不相容的版本。只需在 dependencymanagement 部分新增 spring-cloud-dependency 即可簡化依賴關係管理。刪除所有其他的,因為它們已經由 spring boot 或您擁有的 spring cloud 依賴項管理。

接下來從dependencie 部分的依賴項中刪除版本,並刪除spring-boot-actuator-autoconfiguration 依賴項,該依賴項包含在spring-boot -starter 中。

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.13.RELEASE</version>
</parent>

<properties>
    <java.version>1.8</java.version>

    <!-- Swagger Dependencies -->
    <springfox-swagger2.version>2.4.0</springfox-swagger2.version>

   
</properties>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Hoxton.SR12</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <!-- Swagger Dependencies-->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>${springfox-swagger2.version}</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>${springfox-swagger2.version}</version>
        </dependency>
        <!-- Testing dependencies -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-staticdocs</artifactId>
            <version>${springfox-swagger2.version}</version>
        </dependency>
    </dependencies>
</dependencyManagement>
<dependencies>
  
    <!-- Spring dependencies -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.retry</groupId>
        <artifactId>spring-retry</artifactId>
    </dependency>

    <!-- Spring Cloud Starter -->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-openfeign</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-vault-config</artifactId>
    </dependency>
   
</dependencies>

現在,依賴項由相容版本中的 spring boot 和 spring cloud 正確管理。

以上是正確的應用程式類別路徑,使其包含 org.springframework.beans.factory.config.ConfigurableListableBeanFactory 的單一相容版本的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:stackoverflow.com。如有侵權,請聯絡admin@php.cn刪除