【问题标题】:Upgraded spring boot from 2.1.9 to 2.2.0 , now getting exception while starting将 spring boot 从 2.1.9 升级到 2.2.0 ,现在启动时出现异常
【发布时间】:2020-02-21 02:22:42
【问题描述】:

我将 spring boot 从 2.1.9 升级到 2.2.0 现在我在启动应用程序时遇到了一些异常

java:openjdk11 春季启动:v2.2.0.RELEASE

我尝试从以下位置删除 jar 并进行 mvn clean install,但仍然没有运气。

.m2/repository/org/springframework/boot/spring-boot-actuator/2.2.0.RELEASE/spring-boot-actuator-2.2.0.RELEASE.jar

错误:


***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.cloud.client.discovery.health.DiscoveryCompositeHealthIndicator.<init>(DiscoveryCompositeHealthIndicator.java:41)

The following method did not exist:

    org.springframework.boot.actuate.health.CompositeHealthIndicator.<init>(Lorg/springframework/boot/actuate/health/HealthAggregator;)V

The method's class, org.springframework.boot.actuate.health.CompositeHealthIndicator, is available from the following locations:

    jar:file:/C:/Users/regosa/.m2/repository/org/springframework/boot/spring-boot-actuator/2.2.0.RELEASE/spring-boot-actuator-2.2.0.RELEASE.jar!/org/springframework/boot/actuate/health/CompositeHealthIndicator.class

It was loaded from the following location:

    file:/C:/Users/regosa/.m2/repository/org/springframework/boot/spring-boot-actuator/2.2.0.RELEASE/spring-boot-actuator-2.2.0.RELEASE.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.boot.actuate.health.CompositeHealthIndicator

Pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.xxxxx.business.workflow</groupId>
    <artifactId>xxxxx-component-workflow-starter</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>xxxxx-component-workflow-starter</name>
    <description>xxxxx-component-workflow-starter</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.0.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>11</java.version>
        <jaxb-runtime.version>2.4.0-b180830.0438</jaxb-runtime.version>
        <spring-cloud.version>Greenwich.M1</spring-cloud.version>
       <zeebe-version>0.20.1</zeebe-version>    
        <google-guava.version>27.0.1-jre</google-guava.version>
        <xxxxx.version>1.0</xxxxx.version>
        <swagger.version>2.9.2</swagger.version>
        <jjwt.version>0.9.1</jjwt.version>
        <json.version>20180813</json.version>
        <slf4j-api.version>1.7.25</slf4j-api.version>
        <mysql.version>8.0.11</mysql.version>
        <mongo-java-driver.version>3.10.1</mongo-java-driver.version>
        <commons-io.version>2.6</commons-io.version>
        <commons-lang.version>2.6</commons-lang.version>
        <commons-pool2.version>2.5.0</commons-pool2.version>
        <redis.version>3.1.0</redis.version>
        <velocity.version>1.7</velocity.version>
        <velocity-tools.version>2.0</velocity-tools.version>
        <logstash-logback-encoder.version>5.3</logstash-logback-encoder.version>
        <httpclient.version>4.5.6</httpclient.version>
        <jaxb-runtime.version>2.4.0-b180830.0438</jaxb-runtime.version>
        <env>local</env>
    </properties>   

    <dependencies>
        <!-- Start: Spring Libraries -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</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-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-sleuth</artifactId>
        </dependency>
        <!-- End: Spring Libraries -->

        <!-- Adding JAXB Runtime since it is not shipped with JDK 9+ -->
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
            <version>${jaxb-runtime.version}</version>
        </dependency>

        <!-- Start: xxxxx Libraries -->
        <dependency>
            <groupId>com.xxxxx</groupId>
            <artifactId>xxxxx-entity</artifactId>
            <version>${xxxxx.version}</version>
        </dependency>
        <dependency>
            <groupId>com.xxxxx</groupId>
            <artifactId>xxxxx-redis</artifactId>
            <version>${xxxxx.version}</version>
        </dependency>
        <dependency>
            <groupId>com.xxxxx</groupId>
            <artifactId>xxxxx-mongo</artifactId>
            <version>${xxxxx.version}</version>
        </dependency>           
        <dependency>
            <groupId>com.xxxxx</groupId>
            <artifactId>xxxxx-util</artifactId>
            <version>${xxxxx.version}</version>
        </dependency>
        <dependency>
            <groupId>com.xxxxx.model</groupId>
            <artifactId>xxxxx-model</artifactId>
            <version>${xxxxx.version}</version>
        </dependency>
        <dependency>
            <groupId>com.xxxxx.service</groupId>
            <artifactId>xxxxx-common-service</artifactId>
            <version>${xxxxx.version}</version>
        </dependency>
        <dependency>
            <groupId>com.xxxxx.service</groupId>
            <artifactId>xxxxx-common-messaging</artifactId>
            <version>${xxxxx.version}</version>
        </dependency>   
        <dependency>
            <groupId>com.xxxxx.service</groupId>
            <artifactId>xxxxx-common-security</artifactId>
            <version>${xxxxx.version}</version>
        </dependency>           
        <!-- End: xxxxx Libraries -->

        <!--  Adding Zeebe client as part of the Spring Startup -->     
        <dependency>
            <groupId>io.zeebe</groupId>
            <artifactId>zeebe-client-java</artifactId>
            <version>${zeebe-version}</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>${google-guava.version}</version>
        </dependency>

        <!-- Logstash Log Encoder -->
        <dependency> 
            <groupId>net.logstash.logback</groupId> 
            <artifactId>logstash-logback-encoder</artifactId> 
            <version>${logstash-logback-encoder.version}</version> 
        </dependency>

        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.version}</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.mongodb/mongo-java-driver -->
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongo-java-driver</artifactId>
            <version>${mongo-java-driver.version}</version>
        </dependency>       

        <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${commons-io.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>${commons-lang.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-pool2 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-pool2</artifactId>
            <version>${commons-pool2.version}</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>${redis.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>${httpclient.version}</version>
        </dependency>

        <!-- Start: Swagger Libraries -->
        <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>${swagger.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>${swagger.version}</version>
        </dependency>
        <!-- End: Swagger Libraries -->

        <!-- Start: Spring Boot and Security Test Libraries -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- End: Spring Boot and Security Test Libraries -->

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

    <build>
        <finalName>xxxxx-component-workflow-starter</finalName>
        <filters>
            <filter>${env}-build.properties</filter>
        </filters>
        <resources>
            <resource>
                <filtering>true</filtering>
                <directory>${project.basedir}/src/main/resources</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <release>${java.version}</release>
                </configuration>
            </plugin>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-jar-plugin</artifactId>
              <configuration>
                <archive>
                  <manifestEntries>
                    <Automatic-Module-Name>com.xxxxx.business.workflow.component.starter</Automatic-Module-Name>
                  </manifestEntries>
                </archive>
              </configuration>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories> 
</project>

新异常:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.data.rest.core.support.UnwrappingRepositoryInvokerFactory.<init>(UnwrappingRepositoryInvokerFactory.java:57)

The following method did not exist:

    org.springframework.plugin.core.PluginRegistry.of(Ljava/util/List;)Lorg/springframework/plugin/core/PluginRegistry;

The method's class, org.springframework.plugin.core.PluginRegistry, is available from the following locations:

    jar:file:/C:/Users/regosa/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar!/org/springframework/plugin/core/PluginRegistry.class

It was loaded from the following location:

    file:/C:/Users/regosa/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.plugin.core.PluginRegistry
***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    springfox.documentation.spring.web.plugins.DocumentationPluginsManager.createContextBuilder(DocumentationPluginsManager.java:152)

The following method did not exist:

    org.springframework.plugin.core.PluginRegistry.getPluginFor(Ljava/lang/Object;Lorg/springframework/plugin/core/Plugin;)Lorg/springframework/plugin/core/Plugin;

The method's class, org.springframework.plugin.core.PluginRegistry, is available from the following locations:

    jar:file:/C:/Users/regosa/.m2/repository/org/springframework/plugin/spring-plugin-core/2.0.0.RELEASE/spring-plugin-core-2.0.0.RELEASE.jar!/org/springframework/plugin/core/PluginRegistry.class

It was loaded from the following location:

    file:/C:/Users/regosa/.m2/repository/org/springframework/plugin/spring-plugin-core/2.0.0.RELEASE/spring-plugin-core-2.0.0.RELEASE.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.plugin.core.PluginRegistry

如何解决这个问题?

【问题讨论】:

  • 请发布您的 pom.xml
  • @EugenCovaci 附加 pom.xl
  • 请将Greenwich.M1替换成Greenwich.RELEASE,看看错误是否消失。
  • 最新版本是Greenwich.SR3,你也可以试试这个..
  • @EugenCovaci 谢谢。现在我得到另一个说spring-plugin-core jar中缺少方法的方法。我更新了上面的问题。我现在必须更新哪个插件..?

标签: spring spring-boot spring-boot-actuator


【解决方案1】:

简而言之,问题是由于 spring cloud 和 spring boot 版本不兼容,spring boot 2.2.X 需要 Hoxton release train 而不是 Greenwich。有关详细信息,请参见下文。

这个问题是由于 spring-cloud.version 不兼容造成的。根据 Spring Cloud 文档链接(https://spring.io/projects/spring-cloud),以下是 Spring Boot 兼容性:

发布训练 Spring Boot 兼容性

Release Train      Boot Version

  Hoxton             2.2.x

  Greenwich          2.1.x

因此,如果您将 Spring Boot 更新到 2.2.x,那么也将更新到 Spring Cloud 的 Hoxton 发布系列,即 Hoxton.RC1(https://spring.io/blog/2019/10/25/spring-cloud-hoxton-rc1-released)

P.S:根据 Spring Cloud 里程碑页面,Hoxton.RELEASE 将于 2019 年 11 月 18 日到期 (https://github.com/spring-cloud/spring-cloud-release/milestones)

【讨论】:

  • 这对我有用。我在 Spring Boot 2.2.4 中使用 Greenwich.RELEASE,当我开始使用 spring-boot-starter-actuator 时,它开始出现问题。与问题中提到的相同的错误日志。更新到 Hoxton.SR1 并成功启动。
【解决方案2】:

实际上 springfox 与 Spring-Boot 2.2.0 不兼容。看来springfox已经死了。

您可以改为使用:SpringDoc OpenApi

【讨论】:

【解决方案3】:

这似乎是一个已知问题:https://github.com/spring-cloud/spring-cloud-netflix/issues/3410

如果您在 Spring Boot 应用程序中使用 Spring Cloud 依赖项,请确保您在类路径中具有正确的 Spring Cloud 版本!目前只有 Spring Cloud 的“Hoxton”(https://spring.io/blog/2019/08/19/spring-cloud-hoxton-m2-released) release train 支持 Spring Boot 2.2。

【讨论】:

  • 谢谢,现在我又遇到了一个例外。我在上面更新了问题
  • 这是一个错误。我需要更新任何库吗?
  • 确认Greenwich.SR3不适用于Spring Boot 2.2.0,您需要添加maven { url 'https://repo.spring.io/milestone' }并替换Hoxton.RC1上的格林威治
【解决方案4】:

更新您的 springfox-swagger 版本。我已经升级了 springfox 2.9.2,使用 boot 2.2.2 运行

SpringFox 需要 1.2.0 版本,但 Spring Boot 2.2.2 本身并没有引入这个。所以你不知何故在你的类路径中得到了 spring-plugin-core-1.2.0.RELEASE。然后它就可以正常工作了

【讨论】:

    【解决方案5】:
    <springBootVersion>2.2.4.RELEASE</springBootVersion>
    

    支持的云版本。霍克斯顿.M2

    <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Hoxton.M2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        ...
    </dependencies>
    

    【讨论】:

      【解决方案6】:

      正如user10871691P3arl 已经指出的那样,spring-plugin-core 依赖项使用错误的版本1.2.0.RELEASE 解决。为了强制使用正确的2.0.0.RELEASE,您必须

      • 要么排除错误的传递依赖并指定正确的,
      • 或在您的pom.xml 中锁定(!)该依赖版本。这是在 &lt;dependenciesManagement&gt; 块中完成的,而不是在 &lt;dependencies&gt; 块中。

      &lt;dependenciesManagement&gt; 块中使用版本固定的 Springfox 3.0.0 示例:

      <spring-plugin-core.version>2.0.0.RELEASE</spring-plugin-core.version>
      <springfox.version>3.0.0</springfox.version>
      ...
      
      <dependencyManagement>
        <dependencies>
          <!-- Fix wrong resolved `spring-plugin-core` dependency version for springfox -->
          <dependency>
            <groupId>org.springframework.plugin</groupId>
            <artifactId>spring-plugin-core</artifactId>
            <version>${spring-plugin-core.version}</version>
          </dependency>
      
          <!-- API Documentation -->
          <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-boot-starter</artifactId>
            <version>${springfox.version}</version>
          </dependency>
        </dependencies>
      </dependencyManagement>
      
      <dependencies>
        <!-- API Documentation -->
        <dependency>
          <groupId>io.springfox</groupId>
          <artifactId>springfox-boot-starter</artifactId>
        </dependency>
      </dependencies>
      

      【讨论】:

        【解决方案7】:

        这很奇怪。 spring-plugin-core 版本应该是 2.0.0,而不是 1.2.0。让我们升级它:

        <!-- https://mvnrepository.com/artifact/org.springframework.plugin/spring-plugin-core -->
        <dependency>
            <groupId>org.springframework.plugin</groupId>
            <artifactId>spring-plugin-core</artifactId>
            <version>2.0.0.RELEASE</version>
        </dependency>
        

        【讨论】:

        • 仍然没有运气从 spring-plugin-core 库中获得其他异常(没有找到方法。)。我已经更新了上述问题中的错误信息
        • @JoysonRego 运行 mvn dependency:tree 并将结果粘贴到错误下方。
        • @JoysonRego 我不认为你可以让它工作,除非你放弃 springfox 依赖。他们使用的是旧版本的spring-plugin-core
        • @JoysonRego 不是。
        【解决方案8】:

        在添加更新的插件核心依赖项后,我也面临同样的问题。现在已经解决了。

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

        【讨论】:

          【解决方案9】:

          如果 spring-plugin-core-1.2.0.RELEASE 在您的项目中不起作用,那么另一种方法是将 springfox-swagger 与 3.0.0-SNAPSHOT 版本一起使用。对于这个版本,它有不同的存储库。 仓库地址:http://oss.jfrog.org/artifactory/oss-snapshot-local/

          它将使用@EnableSwagger2WebMvc 注解而不是@EnableSwagger2。

          【讨论】:

            【解决方案10】:

            我将 Springfox Swagger2 升级到 3.0.0 版本,将 spring 插件代码升级到 2.0.0.RELEASE 版本。它对我有用。 Spring Boot 版本 - 2.3.9.RELEASE

            <dependency>
                    <groupId>org.springframework.plugin</groupId>
                    <artifactId>spring-plugin-core</artifactId>
                    <version>2.0.0.RELEASE</version>
                </dependency>
                <dependency>
                    <groupId>io.springfox</groupId>
                    <artifactId>springfox-swagger2</artifactId>
                    <version>3.0.0</version>
                </dependency>
                <dependency>
                    <groupId>io.springfox</groupId>
                    <artifactId>springfox-swagger-ui</artifactId>
                    <version>3.0.0</version>
                </dependency>
            

            【讨论】:

              猜你喜欢
              • 2020-04-26
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2018-03-05
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多