Spring-boot 项目中使用 jackson 遇到的一个问题
jackson介绍
java代码中实现序列化和反序列化的工具类
jackson使用Demo
https://github.com/Naylor55/JavaDebrisCode/tree/branch_Java-Serializable/javaserializable
Ideal控制台报错信息
2019-05-22 15:43:20.333 [main] ERROR org.springframework.boot.SpringApplication.reportFailure:837 - Application run failed
java.lang.AbstractMethodError: com.fasterxml.jackson.core.type.ResolvedType.getReferencedType()Lcom/fasterxml/jackson/core/type/ResolvedType;
at com.fasterxml.jackson.core.type.ResolvedType.isReferenceType(ResolvedType.java:59)
at com.fasterxml.jackson.datatype.jdk8.Jdk8TypeModifier.modifyType(Jdk8TypeModifier.java:20)
at com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:413)
at com.fasterxml.jackson.databind.type.TypeFactory.constructType(TypeFactory.java:354)
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.getJavaType(AbstractJackson2HttpMessageConverter.java:323)
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.canRead(AbstractJackson2HttpMessageConverter.java:158)
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.canRead(AbstractJackson2HttpMessageConverter.java:150)
at org.springframework.web.client.RestTemplate$AcceptHeaderRequestCallback.doWithRequest(RestTemplate.java:805)
Disconnected from the target VM, address: '127.0.0.1:57769', transport: 'socket'
at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:868)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:685)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:644)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:564)
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.getRemoteEnvironment(ConfigServicePropertySourceLocator.java:218)
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:96)
at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:94)
at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:628)
at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:364)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:305)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230)
at com.leading.WarehouseserviceApplication.main(WarehouseserviceApplication.java:50)
报错原因
Spring-Boot框架自身默认就引用了jackson,如果你在自己的开发项目中再次引用,就会有冲突。然而,JVM 不会告诉你是引用有冲突,而是直接给你一个类型有问题的提示。意思就是我只能告诉你类型有问题,具体的你自己查吧。IDEAL 作为一个开发工具,在这点上面也没有做出点贡献。Java这个生态缺陷还是很大的!!!
spriing-boot 默认引用
自己项目的pom中找到:org.springframework.boot , 并点击进去。
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version>
<relativePath />
</parent>
然后再找:spriing-boot-dependencies ,并点击进去
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.0.6.RELEASE</version>
<relativePath>../../spring-boot-dependencies</relativePath>
</parent>
然后就可以看到spring-boot 对jackson 的引用,如下图

解决办法
在当前开发项目的pom文件中删除对jackson的依赖,即删除如下图所示

Spring-boot 项目中使用 jackson 遇到的一个问题的更多相关文章
- 在Spring Boot项目中使用Spock框架
转载:https://www.jianshu.com/p/f1e354d382cd Spock框架是基于Groovy语言的测试框架,Groovy与Java具备良好的互操作性,因此可以在Spring B ...
- 在Spring Boot项目中使用Spock测试框架
本文首发于个人网站:在Spring Boot项目中使用Spock测试框架 Spock框架是基于Groovy语言的测试框架,Groovy与Java具备良好的互操作性,因此可以在Spring Boot项目 ...
- 你真的理解 Spring Boot 项目中的 parent 吗?
前面和大伙聊了 Spring Boot 项目的三种创建方式,这三种创建方式,无论是哪一种,创建成功后,pom.xml 坐标文件中都有如下一段引用: <parent> <groupId ...
- Spring Boot项目中使用Swagger2
Swagger2是一款restful接口文档在线生成和在线接口调试工具,Swagger2在Swagger1.x版本的基础上做了些改进,下面是在一个Spring Boot项目中引入Swagger2的简要 ...
- Spring Boot2 系列教程(三)理解 Spring Boot 项目中的 parent
前面和大伙聊了 Spring Boot 项目的三种创建方式,这三种创建方式,无论是哪一种,创建成功后,pom.xml 坐标文件中都有如下一段引用: <parent> <groupId ...
- Spring Boot项目中使用Mockito
本文首发于个人网站:Spring Boot项目中使用Mockito Spring Boot可以和大部分流行的测试框架协同工作:通过Spring JUnit创建单元测试:生成测试数据初始化数据库用于测试 ...
- Spring Boot项目中如何定制拦截器
本文首发于个人网站:Spring Boot项目中如何定制拦截器 Servlet 过滤器属于Servlet API,和Spring关系不大.除了使用过滤器包装web请求,Spring MVC还提供Han ...
- Spring Boot项目中如何定制PropertyEditors
本文首发于个人网站:Spring Boot项目中如何定制PropertyEditors 在Spring Boot: 定制HTTP消息转换器一文中我们学习了如何配置消息转换器用于HTTP请求和响应数据, ...
- Spring Boot项目中如何定制servlet-filters
本文首发于个人网站:Spring Boot项目中如何定制servlet-filters 在实际的web应用程序中,经常需要在请求(request)外面增加包装用于:记录调用日志.排除有XSS威胁的字符 ...
- Spring Boot 项目中的 parent
前言 我们成功创建Spring Boot之后,pom.xml坐标文件中都会有如下一段引用: <parent> <groupId>org.springframework.boot ...
随机推荐
- JS中不同类型的值比较问题
我们比较数据的时候大多是以下两种情况: 3 > 4 ; "m" > "n" ; 但有时候可能会出现比较符号两侧的数据类型不相同的场景,例如 5 &g ...
- MySQL 当记录不存在时insert,当记录存在时update
MySQL当记录不存在时insert,当记录存在时更新:网上基本有三种解决方法 第一种: 示例一:insert多条记录 假设有一个主键为 client_id 的 clients 表,可以使用下面的语句 ...
- Java8中聚合操作collect、reduce方法详解
Stream的基本概念 Stream和集合的区别: Stream不会自己存储元素.元素储存在底层集合或者根据需要产生.Stream操作符不会改变源对象.相反,它会返回一个持有结果的新的Stream.3 ...
- Selenium-js弹窗浮层
学习过js的小伙伴会发现,我们在一些实例中用到了alert()方法.prompt()方法.prompt()方法,他们都是在屏幕上弹出一个对话框,并且在上面显示括号内的内容,使用这种方法使得页面的交互性 ...
- KVM-快照管理
1.kvm克隆 kvm 虚拟机有两部分组成:img镜像文件和xml配置文件(/etc/libvirt/qemu 克隆命令:virt-clone -o rhel6- 71 -n xuegod63-kvm ...
- xxx was built without full bitcode" 编译错误解决
xxx was built without full bitcode" 编译错误解决 iOS 打包上线 All object files and libraries for bitcode ...
- 搞事情 -- python之线程
简介 操作系统线程理论 线程概念的引入背景 线程的特点 进程和线程的关系 使用线程的实际场景 用户级线程和内核级线程(了解) 线程和python 理论知识 线程的创建Threading.Thread类 ...
- Java中Calendar常用方法总结
//获取当前时刻yyyy-MM-dd HH:mm:ss Calendar calendar = Calendar.getInstance(); SimpleDateFormat sdf = new S ...
- [转]WebKit CSS3 动画基础
前几天在Qzone上看到css3动画,非常神奇,所以也学习了一下.首先看看效果http://www.css88.com/demo/css3_Animation/ 很悲剧的是css3动画现在只有WebK ...
- SQL介绍(1)
SQL 是用于访问和处理数据库的标准的计算机语言. SQL,指结构化查询语言,全称是 Structured Query Language. SQL 让您可以访问和处理数据库. SQL 是一种 ANSI ...