gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 02:53:46 28 4
gpt4 key购买 nike

我有一个 spring-boot 2 项目,其中有很多子模块。

某些模块使用的库包括 jackson-databind 。我为他们添加了排除项。当做mvn dependency:tree | grep jackson-databind时,我没有2.2.2依赖关系。使用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
  • 通过导入maven项目导入项目

现在可以了。

关于java - 使用多模块 Maven 项目时 Eclipse 的类路径问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57091306/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com