简体   繁体   中英

classpath problems with eclipse when working with a multi-module maven project

I have a spring-boot 2 project with quite a few sub-modules.

Some modules use libraries which include jackson-databind . I added exclusions for them. When doing a mvn dependency:tree | grep jackson-databind mvn dependency:tree | grep jackson-databind , I have NO 2.2.2 dependencies. Using mvn spring-boot:run works flawlessly. However, starting the application in eclipse leads to the error below.

Where should I search for the source of error?

***************************
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.http.converter.json.Jackson2ObjectMapperBuilder.registerWellKnownModulesIfAvailable(Jackson2ObjectMapperBuilder.java:777)

The following method did not exist:

    com.fasterxml.jackson.databind.Module.getTypeId()Ljava/lang/Object;

The method's class, com.fasterxml.jackson.databind.Module, is available from the following locations:

    jar:file:/C:/Users/somebody/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.2.2/jackson-databind-2.2.2.jar!/com/fasterxml/jackson/databind/Module.class
    jar:file:/C:/Users/somebody/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.6.6/jackson-databind-2.6.6.jar!/com/fasterxml/jackson/databind/Module.class
    jar:file:/C:/Users/somebody/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.9.8/jackson-databind-2.9.8.jar!/com/fasterxml/jackson/databind/Module.class
    jar:file:/C:/Users/somebody/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.8.8/jackson-databind-2.8.8.jar!/com/fasterxml/jackson/databind/Module.class

It was loaded from the following location:

    file:/C:/Users/somebody/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.2.2/jackson-databind-2.2.2.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of com.fasterxml.jackson.databind.Module

uhm. Seems that the project was imported incorrectly into eclipse. maybe mvn eclipse:eclipse is to blame.

  • remove projects from workspace
  • remove all eclipse project files ( .project , .classpath , etc)
  • put them into .gitignore
  • import projects via import maven project

now it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM