SpringBoot使用devtools导致的类型转换异常
- 遇到的问题:
SpringBoot项目中的热部署引发的血的教训,报错代码位置:
1 XStream xStream1 = new XStream();
2 xStream1.autodetectAnnotations(true);
3 xStream1.alias("InterBOSS", InterBossHeader.class);
4 InterBossHeader resp = (InterBossHeader) xStream1.fromXML(response);项目中的pom配置:
1 <dependency>
2 <groupId>org.springframework.boot</groupId>
3 <artifactId>spring-boot-devtools</artifactId>
4 <scope>runtime</scope>
5 </dependency> - 问题的分析:
以上配置发现同样的类型(InterBossHeader)竟然出现了类型转换异常!WQNMMP—。—
分析出ClassLoader不同导致的类型转换异常,Spring的dev-tools为了实现重新装载class自己实现了一个类加载器,来加载项目中会改变的类,方便重启时将新改动的内容更新进来,其实其中官方文档中是有做说明的:
1 By default, any open project in your IDE will be loaded using the
2 “restart” classloader, and any regular .jar file will be loaded using
3 the “base” classloader. If you work on a multi-module project, and not
4 each module is imported into your IDE, you may need to customize
5 things. To do this you can create a
6 META-INF/spring-devtools.properties file.
7 The spring-devtools.properties file can contain restart.exclude. and
8 restart.include. prefixed properties. The include elements are items
9 that should be pulled up into the “restart” classloader, and the
10 exclude elements are items that should be pushed down into the “base”
11 classloader. The value of the property is a regex pattern that will be
12 applied to the classpath. - 解决办法:
第一种解决方案:在resources目录下面创建META_INF文件夹,然后创建spring-devtools.properties文件,文件加上类似下面的配置:
restart.exclude.companycommonlibs=/mycorp-common-[\w-]+.jar
restart.include.projectcommon=/mycorp-myproj-[\w-]+.jar
第二种解决方案:不使用spring-boot-devtools(当我没说)
引用:试水流连
SpringBoot使用devtools导致的类型转换异常的更多相关文章
- springboot中redis取缓存类型转换异常
异常如下: [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested ...
- weblogic启动节点服务java.lang.ClassCastException:com.octestring.vde.backend.BackendRoot cannot be cast to com.octestring.vde.backend.standard.BackendStandard类型转换异常
weblogic启动节点服务器报错,java.lang.ClassCastException:com.octestring.vde.backend.BackendRoot cannot be cast ...
- springboot之DevTools热部署的简单原理解析
IDEA新建springboot选择DevTools springboot-devtools模块能够实现热部署,添加类.添加方法,修改配置文件,修改页面等,都能实现热部署. 原理就是重启项目,但比手动 ...
- 最近走过的坑 :slf4j 多个实现 hibernate 类型转换异常 bean依赖问题
最近走过的坑 slf4j 多个实现 主要是maven依赖中存在多个slf4j的实现类,在引入的依赖中排除对应的依赖就可以 <dependency> <groupId>xxxxx ...
- Oracle 监听器日志文件过大导致监听异常
Oracle 监听器日志文件过大导致监听异常 db版本:11.2.0.1 os版本:windows2008 现象: 应用异常,无法连接数据库.登陆数据库服务器,查看监听已经断掉.尝试重启监听,重启失败 ...
- oracle所在磁盘空间不足导致了数据库异常
oracle所在磁盘空间不足导致了数据库异常.需要减小数据文件的大小来解决. 1.检查数据文件的名称和编号 select file#,name from v$datafile; 2.看哪个数据文件所占 ...
- Android的debug.keystore拒绝访问导致的生成异常及解决方案
构建Android应用程序的时候输出异常:[apkbuilder] keytool 错误: java.io.FileNotFoundException: C:\Users\my\.android\de ...
- 关于FusionCharts图表宽度width的设置问题导致图表显示异常的解决办法
关于FusionCharts图表宽度width的设置问题导致图表显示异常的解决办法 题设: 经常使用FusionCharts图表的朋友可能会遇到这个问题.就是在FusionCharts显示的时候有时候 ...
- 堆内存泄漏移除导致tcp链接异常高
故障现象: 1:活动前端Nginx服务器TCP连接数到1万多 2:活动后端Tomcat其中1台TCP连接数达4千,并且CPU瞬间到780%(配置8核16G),内存正常 3:重启后端Tomcat后,TC ...
随机推荐
- Wireshark网络分析工具(一)
关于Wireshark,熟悉网络或网络性能方面的同学应该知道,使用Wireshark工具通过抓取数据包,对系统网络问题进行分析,该工具简单.易用.易学! 百度百科上面是这样描述的:Wireshark( ...
- HTTP 状态码简介(对照)
HTTP状态码 当浏览者访问一个网页时,浏览者的浏览器会向网页所在服务器发出请求.当浏览器接收并显示网页前,此网页所在的服务器会返回一个包含HTTP状态码的信息头(server header)用以响应 ...
- 内置函数: filter 和 map
内置函数———filter和map filter filter() 函数用于过滤序列,过滤掉不符合条件的元素,返回由符合条件元素组成的新列表.接收两个参数,第一个为函数,第二个为序列,序列的每个元素作 ...
- 检查arg是方法还是函数?
from types import MethodType,FunctionType def check(arg): """ 检查arg是方法还是函数? :param ar ...
- hbase中清空整张表的数据
hbase(main):005:0> truncate 'fr:test' Truncating 'FaceBase' table (it may take a while): - Disabl ...
- SpringMVC:学习笔记(5)——数据绑定及表单标签
SpringMVC——数据绑定及表单标签 理解数据绑定 为什么要使用数据绑定 基于HTTP特性,所有的用户输入的请求参数类型都是String,比如下面表单: 按照我们以往所学,如果要获取请求的所有参数 ...
- pyhton3 logging模块
1.简单的将日志打印到屏幕 import logging logging.debug('This is debug message')logging.info('This is info mess ...
- Yii2.0数据库查询实例(三)
常用查询: // WHERE admin_id >= 10 LIMIT 0,10 User::find()->])->offset()->limit()->all() / ...
- 转:CWebBrowser2去除边框、滚动条、右键菜单
http://blog.csdn.net/tangyin025/article/details/8675513 添加CWebBrowser2类 右键项目-〉Add-〉Class...-〉MFC-〉MF ...
- Linux下32位与64位数据类型大小
Redhat Enterprise Linux 32 Redhat Enterprise Linux 64