繁体   English   中英

使用多模块Maven项目时,Eclipse的类路径问题

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

我有一个带有很多子模块的spring-boot 2项目。

一些模块使用包含jackson-databind库。 我为他们添加了排除对象。 在执行mvn dependency:tree | grep jackson-databind mvn dependency:tree | grep jackson-databind ,我没有2.2.2依赖项。 使用mvn spring-boot:run可以完美mvn spring-boot:run 但是,以Eclipse启动应用程序会导致以下错误。

我应该在哪里寻找错误的根源?

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

似乎项目被错误地导入了eclipse中。 也许是mvn eclipse:eclipse怪罪了。

  • 从工作区中删除项目
  • 删除所有的Eclipse项目文件( .project.classpath等)
  • 将它们放入.gitignore
  • 通过import maven project

现在可以了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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