SpringCloud study notes -Eureka problems in the process of building

Question 1: Gson packet collisions, start Server error when specific information is described as follows:

Description:

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

    java.lang.invoke.MethodHandleNatives.resolve(Native Method)

The following method did not exist:

    com.google.gson.GsonBuilder.setLenient()Lcom/google/gson/GsonBuilder;

The method's class, com.google.gson.GsonBuilder, is available from the following locations:

    jar: file: / C: /Users/farida/.m2/repository/com/google/code/gson/gson/2.1/gson-2.1.jar! /com/google/gson/GsonBuilder.class

It was loaded from the following location:

    file: / C: /Users/farida/.m2/repository/com/google/code/gson/gson/2.1/gson-2.1.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of com.google.gson.GsonBuilder

  Solution: Exclude gson package eureka itself used

    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
      <exclusions>
        <exclusion>
          <groupId>com.google.code.gson</groupId>
          <artifactId>gson</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

 

Guess you like

Origin www.cnblogs.com/guolaoshi/p/12319725.html