在项目中,需要使用XStream将xml string转成相应的对象,却报出了java.lang.ClassCastException: com.model.test cannot be cast to com.model.test的错误。
原因:
项目中应该是采用了热部署,devtools,因为累加载器的不同所以会导致类型转换失败
措施:
在pom.xml中将以下代码注释掉:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>