当前位置: 首页 > 知识库问答 >
问题:

Spring Boot升级后“未找到提供程序com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule”

胡弘毅
2023-03-14

当我尝试启动应用程序时,在将Spring Boot从2.1.5升级到2.2.2之后,我收到了这个异常消息。

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'feignContract' defined in org.springframework.cloud.openfeign.FeignClientsConfiguration: Unsatisfied dependency expressed through method 'feignContract' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'feignConversionService' defined in org.springframework.cloud.openfeign.FeignClientsConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'feignConversionService' threw exception; nested exception is java.util.ServiceConfigurationError: com.fasterxml.jackson.databind.Module: Provider com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule not found
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
    at org.springframework.cloud.context.named.NamedContextFactory.createContext(NamedContextFactory.java:136)
    at org.springframework.cloud.context.named.NamedContextFactory.getContext(NamedContextFactory.java:101)
    at org.springframework.cloud.context.named.NamedContextFactory.getInstance(NamedContextFactory.java:145)
    at org.springframework.cloud.openfeign.FeignClientFactoryBean.get(FeignClientFactoryBean.java:225)
    at org.springframework.cloud.openfeign.FeignClientFactoryBean.feign(FeignClientFactoryBean.java:86)
    at org.springframework.cloud.openfeign.FeignClientFactoryBean.getTarget(FeignClientFactoryBean.java:262)
    at org.springframework.cloud.openfeign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:252)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:171)
    ... 169 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'feignConversionService' defined in org.springframework.cloud.openfeign.FeignClientsConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'feignConversionService' threw exception; nested exception is java.util.ServiceConfigurationError: com.fasterxml.jackson.databind.Module: Provider com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule not found
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:656)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:484)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1287)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789)
    ... 189 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'feignConversionService' threw exception; nested exception is java.util.ServiceConfigurationError: com.fasterxml.jackson.databind.Module: Provider com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule not found
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651)
    ... 203 common frames omitted
Caused by: java.util.ServiceConfigurationError: com.fasterxml.jackson.databind.Module: Provider com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule not found
    at java.util.ServiceLoader.fail(ServiceLoader.java:239)
    at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
    at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:372)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
    at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
    at com.fasterxml.jackson.databind.ObjectMapper.findModules(ObjectMapper.java:1054)
    at com.fasterxml.jackson.databind.ObjectMapper.findModules(ObjectMapper.java:1038)
    at com.fasterxml.jackson.databind.ObjectMapper.findAndRegisterModules(ObjectMapper.java:1088)
    at at.porscheinformatik.retail.integration.api.formatter.DefaultDateTimeFormatter.<init>(DefaultDateTimeFormatter.java:24)
    at at.porscheinformatik.sbo.integration.impl.rest.feign.RestIntegrationFeignConfiguration.registerFormatters(RestIntegrationFeignConfiguration.java:30)
    at org.springframework.cloud.openfeign.FeignClientsConfiguration.feignConversionService(FeignClientsConfiguration.java:117)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)

当我刚刚升级到SpringBoot2.2.1时,这个异常不会发生。

添加依赖项后:

<dependency>
      <groupId>com.fasterxml.jackson.module</groupId>
      <artifactId>jackson-module-jaxb-annotations</artifactId>
</dependency>

它适用于2.2.2。

所以我的问题是,为什么在这次Spring Boot升级之后突然需要手动添加依赖项。

共有2个答案

郑光济
2023-03-14

假设您的应用程序正在使用/包括Liquibase,这是因为Liquibase core中有一个错误的文件,该html" target="_blank">文件正在为Jackson模块定义SPI扩展名,但没有为该模块提供实现:https://github.com/liquibase/liquibase/issues/1051

OP中列出的解决方案已经足够了,因为它为SPI文件中引用的Jackson模块提供了实现,但是您也可以将Liquibase升级到

对于Gradle,依赖关系是:

implementation 'org.liquibase:liquibase-core:3.10.3'

更多信息:https://github.com/logstash/logstash-logback-encoder/issues/387#issuecomment-581603444

钱朝明
2023-03-14

我将研究您的依赖项,它们可能使用xml作为配置。我使用的是SpringBoot2.3.1,在添加Liquibase支持之前,我不需要这个依赖项。因为我使用xml进行Liquibase配置,所以在启动时看到了相同的错误。一旦我添加了这个依赖项,错误就消失了。

 类似资料:
  • 我正在尝试使用JPA和EclipseLink来持久化元素。所以我创建了一个类来持久化 等等。我创建了一个类来“使用”: 然后,我有以下persistence.xml: 但是,即使我改变了属性,我也有同样的错误: 线程"main"中的异常javax.persistence.PeristenceException:没有名为MyPU的EntityManager的持久性提供程序(当调用工厂=Persist

  • 我用Play2.0创建了一个应用程序。我实现了scribe-java库来使用一些OAuth服务。直到今天,一切都很好,但当我升级jdk并重新启动服务器时,我不能使用scribe-java库。它似乎在sun.security包中使用了和类,但找不到。 “java-version”返回: 播放2.0 StackTrace:

  • 问题内容: 我正在尝试将Entity Framework与MySQL配合使用,但出现上述错误。我安装了最新的MySQL连接器。 完整错误为: 但是,我找不到任何建议说明您如何在“ entityFramework”部分中进行注册的内容。 其他一些帖子(例如)建议将提供程序添加到该 部分中,如下所示: 但这不起作用,因为它声称名称是重复的。而且,如果我实际上遍历了,我可以看到最后一个是MySQL提供程

  • 我目前正在花时间将我的项目从Laravel 4.2升级到Laravel 5.2。 在经历了很多麻烦之后,我设法使5.1版本正常运行,因此我启动了5.1到5.2程序,如官方文件中所述:https://laravel.com/docs/5.2/upgrade#upgrade-5.2.0 第一步之后,我的composer.json是这样的: 我还更新了app.php配置以删除提供程序部分中的Artisa

  • 一、简介 本章节主要介绍PHPCMS V9程序升级方式 二、目录 离线升级 在线升级

  • 问题内容: 我正在尝试“定制” mongolab示例以适合我自己的REST API。现在我遇到了这个错误,我不确定自己在做什么错: 这是我的控制器: 这是模块: 问题答案: 您的代码看起来不错,实际上,当将其复制并粘贴到示例jsFiddle中时,它可以正常工作(除了调用本身): http //jsfiddle.net/VGaWD/ 很难说发生了什么而没有看到更完整的示例,但是我希望上面的jsFid