Stefanjiangye 2022-07-15 15:19 采纳率: 33.3%
浏览 135
已结题

Jackson替换fastjson,swagger-ui启动报错

最近需要将项目中所有fastjson换成Jackson,但问题来了,依赖去掉fastjson以后swagger-ui报错,不知道大,神有没有遇到,有没有办法解决或是其他方式替换

Caused by: com.google.common.util.concurrent.ExecutionError: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: Lcom/alibaba/fastjson/serializer/PropertyFilter;
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2212) ~[guava-20.0.jar:na]
    at com.google.common.cache.LocalCache.get(LocalCache.java:4053) ~[guava-20.0.jar:na]
    at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4057) ~[guava-20.0.jar:na]
    at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4986) ~[guava-20.0.jar:na]
    at springfox.documentation.schema.CachingModelDependencyProvider.dependentModels(CachingModelDependencyProvider.java:58) ~[springfox-schema-2.9.2.jar:null]
    at springfox.documentation.schema.DefaultModelProvider.dependencies(DefaultModelProvider.java:128) ~[springfox-schema-2.9.2.jar:null]
    at springfox.documentation.schema.CachingModelProvider.dependencies(CachingModelProvider.java:68) ~[springfox-schema-2.9.2.jar:null]
    at springfox.documentation.spring.web.scanners.ApiModelReader.populateDependencies(ApiModelReader.java:136) ~[springfox-spring-web-2.9.2.jar:null]
    at springfox.documentation.spring.web.scanners.ApiModelReader.read(ApiModelReader.java:78) ~[springfox-spring-web-2.9.2.jar:null]
    at springfox.documentation.spring.web.scanners.ApiListingScanner.scan(ApiListingScanner.java:133) ~[springfox-spring-web-2.9.2.jar:null]
    at springfox.documentation.spring.web.scanners.ApiDocumentationScanner.scan(ApiDocumentationScanner.java:71) ~[springfox-spring-web-2.9.2.jar:null]
    at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.scanDocumentation(DocumentationPluginsBootstrapper.java:101) ~[springfox-spring-web-2.9.2.jar:null]
    at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.start(DocumentationPluginsBootstrapper.java:167) ~[springfox-spring-web-2.9.2.jar:null]
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:173) ~[spring-context-4.3.25.RELEASE.jar:4.3.25.RELEASE]
    ... 14 common frames omitted
Caused by: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: Lcom/alibaba/fastjson/serializer/PropertyFilter;
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2212) ~[guava-20.0.jar:na]
    at com.google.common.cache.LocalCache.get(LocalCache.java:4053) ~[guava-20.0.jar:na]
    at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4057) ~[guava-20.0.jar:na]
    at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4986) ~[guava-20.0.jar:na]
    at springfox.documentation.schema.property.CachingModelPropertiesProvider.propertiesFor(CachingModelPropertiesProvider.java:64) ~[springfox-schema-2.9.2.jar:null]
    at springfox.documentation.schema.DefaultModelDependencyProvider.propertiesFor(DefaultModelDependencyProvider.java:241) ~[springfox-schema-2.9.2.jar:null]
    at springfox.documentation.schema.DefaultModelDependencyProvider.nonTrivialProperties(DefaultModelDependencyProvider.java:189) ~[springfox-schema-2.9.2.jar:null]
    at springfox.documentation.schema.DefaultModelDependencyProvider.resolvedPropertiesAndFields(DefaultModelDependencyProvider.java:176) ~[springfox-schema-2.9.2.jar:null]
    at springfox.documentation.schema.DefaultModelDependencyProvider.resolvedDependencies(DefaultModelDependencyProvider.java:120) ~[springfox-schema-2.9.2.jar:null]
    at springfox.documentation.schema.DefaultModelDependencyProvider.maybeFromCollectionElementType(DefaultModelDependencyProvider.java:220) ~[springfox-schema-2.9.2.jar:null]
    at springfox.documentation.schema.DefaultModelDependencyProvider.resolvedPropertiesAndFields(DefaultModelDependencyProvider.java:181) ~[springfox-schema-2.9.2.jar:null]
    at springfox.documentation.schema.DefaultModelDependencyProvider.resolvedDependencies(DefaultModelDependencyProvider.java:120) ~[springfox-schema-2.9.2.jar:null]
    at springfox.documentation.schema.DefaultModelDependencyProvider.maybeFromCollectionElementType(DefaultModelDependencyProvider.java:220) ~[springfox-schema-2.9.2.jar:null]
    at springfox.documentation.schema.DefaultModelDependencyProvider.resolvedPropertiesAndFields(DefaultModelDependencyProvider.java:181) ~[springfox-schema-2.9.2.jar:null]
    at springfox.documentation.schema.DefaultModelDependencyProvider.resolvedDependencies(DefaultModelDependencyProvider.java:120) ~[springfox-schema-2.9.2.jar:null]
    at springfox.documentation.schema.DefaultModelDependencyProvider.dependentModels(DefaultModelDependencyProvider.java:79) ~[springfox-schema-2.9.2.jar:null]
    at springfox.documentation.schema.CachingModelDependencyProvider$1.load(CachingModelDependencyProvider.java:50) ~[springfox-schema-2.9.2.jar:null]
    at springfox.documentation.schema.CachingModelDependencyProvider$1.load(CachingModelDependencyProvider.java:48) ~[springfox-schema-2.9.2.jar:null]
    at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3628) ~[guava-20.0.jar:na]
    at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2336) ~[guava-20.0.jar:na]
    at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2295) ~[guava-20.0.jar:na]
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2208) ~[guava-20.0.jar:na]
    ... 27 common frames omitted
Caused by: java.lang.NoClassDefFoundError: Lcom/alibaba/fastjson/serializer/PropertyFilter;
    at java.lang.Class.getDeclaredFields0(Native Method) ~[na:1.8.0_131]
    at java.lang.Class.privateGetDeclaredFields(Class.java:2583) ~[na:1.8.0_131]
    at java.lang.Class.getDeclaredFields(Class.java:1916) ~[na:1.8.0_131]
    at com.fasterxml.jackson.databind.util.ClassUtil.getDeclaredFields(ClassUtil.java:937) ~[jackson-databind-2.8.11.3.jar:2.8.11.3]
    at com.fasterxml.jackson.databind.introspect.AnnotatedClass._findFields(AnnotatedClass.java:835) ~[jackson-databind-2.8.11.3.jar:2.8.11.3]
    at com.fasterxml.jackson.databind.introspect.AnnotatedClass._findFields(AnnotatedClass.java:832) ~[jackson-databind-2.8.11.3.jar:2.8.11.3]
    at com.fasterxml.jackson.databind.introspect.AnnotatedClass.resolveFields(AnnotatedClass.java:599) ~[jackson-databind-2.8.11.3.jar:2.8.11.3]
    at com.fasterxml.jackson.databind.introspect.AnnotatedClass.fields(AnnotatedClass.java:371) ~[jackson-databind-2.8.11.3.jar:2.8.11.3]
    at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector._addFields(POJOPropertiesCollector.java:371) ~[jackson-databind-2.8.11.3.jar:2.8.11.3]
    at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector.collectAll(POJOPropertiesCollector.java:302) ~[jackson-databind-2.8.11.3.jar:2.8.11.3]
    at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector.getPropertyMap(POJOPropertiesCollector.java:267) ~[jackson-databind-2.8.11.3.jar:2.8.11.3]
    at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector.getProperties(POJOPropertiesCollector.java:159) ~[jackson-databind-2.8.11.3.jar:2.8.11.3]
    at com.fasterxml.jackson.databind.introspect.BasicBeanDescription._properties(BasicBeanDescription.java:144) ~[jackson-databind-2.8.11.3.jar:2.8.11.3]
    at com.fasterxml.jackson.databind.introspect.BasicBeanDescription.findProperties(BasicBeanDescription.java:219) ~[jackson-databind-2.8.11.3.jar:2.8.11.3]
    at springfox.documentation.schema.property.OptimizedModelPropertiesProvider.propertiesFor(OptimizedModelPropertiesProvider.java:124) ~[springfox-schema-2.9.2.jar:null]
    at springfox.documentation.schema.property.OptimizedModelPropertiesProvider.propertiesFor(OptimizedModelPropertiesProvider.java:118) ~[springfox-schema-2.9.2.jar:null]
    at springfox.documentation.schema.property.CachingModelPropertiesProvider$1.load(CachingModelPropertiesProvider.java:56) ~[springfox-schema-2.9.2.jar:null]
    at springfox.documentation.schema.property.CachingModelPropertiesProvider$1.load(CachingModelPropertiesProvider.java:54) ~[springfox-schema-2.9.2.jar:null]
    at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3628) ~[guava-20.0.jar:na]
    at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2336) ~[guava-20.0.jar:na]
    at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2295) ~[guava-20.0.jar:na]
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2208) ~[guava-20.0.jar:na]
    ... 48 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.alibaba.fastjson.serializer.PropertyFilter
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_131]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_131]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) ~[na:1.8.0_131]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_131]
    ... 70 common frames omitted

  • 写回答

1条回答 默认 最新

  • Tomshidi 2022-07-15 15:56
    关注

    这个问题就很明显了,swagger-ui 本身依赖于阿里的fastjson,你强行移除必然是会报错的。
    这种第三方框架的依赖你是干不掉的,除非你不用swagger-ui了。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 7月25日
  • 已采纳回答 7月25日
  • 修改了问题 7月15日
  • 创建了问题 7月15日

悬赏问题

  • ¥100 有偿,谁有移远的EC200S固件和最新的Qflsh工具。
  • ¥15 找一个QT页面+目标识别(行人检测)的开源项目
  • ¥15 有没有整苹果智能分拣线上图像数据
  • ¥20 有没有人会这个东西的
  • ¥15 cfx考虑调整“enforce system memory limit”参数的设置
  • ¥30 航迹分离,航迹增强,误差分析
  • ¥15 Chrome Manifest扩展引用Ajax-hook库拦截请求失败
  • ¥15 用Ros中的Topic通讯方式控制小乌龟的速度,走矩形;编写订阅器代码
  • ¥15 LLM accuracy检测
  • ¥15 pycharm添加远程解释器报错