• 遇到的问题:
    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导致的类型转换异常的更多相关文章

  1. springboot中redis取缓存类型转换异常

    异常如下: [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested ...

  2. 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 ...

  3. springboot之DevTools热部署的简单原理解析

    IDEA新建springboot选择DevTools springboot-devtools模块能够实现热部署,添加类.添加方法,修改配置文件,修改页面等,都能实现热部署. 原理就是重启项目,但比手动 ...

  4. 最近走过的坑 :slf4j 多个实现 hibernate 类型转换异常 bean依赖问题

    最近走过的坑 slf4j 多个实现 主要是maven依赖中存在多个slf4j的实现类,在引入的依赖中排除对应的依赖就可以 <dependency> <groupId>xxxxx ...

  5. Oracle 监听器日志文件过大导致监听异常

    Oracle 监听器日志文件过大导致监听异常 db版本:11.2.0.1 os版本:windows2008 现象: 应用异常,无法连接数据库.登陆数据库服务器,查看监听已经断掉.尝试重启监听,重启失败 ...

  6. oracle所在磁盘空间不足导致了数据库异常

    oracle所在磁盘空间不足导致了数据库异常.需要减小数据文件的大小来解决. 1.检查数据文件的名称和编号 select file#,name from v$datafile; 2.看哪个数据文件所占 ...

  7. Android的debug.keystore拒绝访问导致的生成异常及解决方案

    构建Android应用程序的时候输出异常:[apkbuilder] keytool 错误: java.io.FileNotFoundException: C:\Users\my\.android\de ...

  8. 关于FusionCharts图表宽度width的设置问题导致图表显示异常的解决办法

    关于FusionCharts图表宽度width的设置问题导致图表显示异常的解决办法 题设: 经常使用FusionCharts图表的朋友可能会遇到这个问题.就是在FusionCharts显示的时候有时候 ...

  9. 堆内存泄漏移除导致tcp链接异常高

    故障现象: 1:活动前端Nginx服务器TCP连接数到1万多 2:活动后端Tomcat其中1台TCP连接数达4千,并且CPU瞬间到780%(配置8核16G),内存正常 3:重启后端Tomcat后,TC ...

随机推荐

  1. php安装pcntl扩展

    1.下载一个同样版本的php(我的是php5.6.27,我下的是php5.6.28) [root@CentOS6 lamp]# wget http://hk1.php.net/get/php-5.6. ...

  2. 关于主键(PRIMARY KEY)和自增(AUTO_INCREMENT)结合使用的知识点

    1.主键(PRIMARY KEY)和自增(AUTO_INCREMENT)同时使用两种写法:    a.主键(PRIMARY KEY)和自增(AUTO_INCREMENT)分两行写        创建一 ...

  3. Python获取位数

    import platform platform.architecture()

  4. python 获取当前运行的 class 和 方法的名字

    # coding=utf-8 import sys class Hello(): def hello(self): print('the name of method is ## {} ##'.for ...

  5. Mac 安装Minikube

    环境信息: guoguo-MacBook-Pro-3:~ guoguo$ docker versionClient: Version:    17.12.0-ce API version:    1. ...

  6. Oracle学习笔记—归档模式

    什么是归档模式 Oracle数据库有联机重做日志,这个日志是记录对数据库所做的修改,比如插入,删除,更新数据等,对这些操作都会记录在联机重做日志里.一般数据库至少要有2个联机重做日志组.当一个联机重做 ...

  7. predis操作大全

    predis是php连接redis的操作库,由于它完全使用php编写,大量使用命名空间以及闭包等功能,只支持php5.3以上版本,故实测性能一般,每秒25000次读写,相信改换c语言编写的php扩展后 ...

  8. Yii2 使用 Beanstalk 队列系统

    参考网址: Beanstalk:https://github.com/kr/beanstalkd Beanstalk console:https://github.com/ptrofimov/bean ...

  9. Word内容修改,以及转PDF

    Word模板内容修改 1.java代码 package com.sicdt.sicsign.web.utils; import java.io.ByteArrayInputStream; import ...

  10. php任务管理器 —— Jobby

    通过一个主crontab任务去维护别的任务 自定义的计划任务完全由PHP编写 任务的执行计划时间表设置与crontab的时间表设置语法一致 在指定的时间内只会运行一个任务 邮件告警异常退出任务 在ro ...