ObjectMapper objectMapper = new ObjectMapper(); Zjzfxmsp zfsp = objectMapper.convertValue(object, Zjzfxmsp.class);
https://blog.csdn.net/jxwen1/article/details/104159222
上面的方式是可行的。
在这之前我尝试了
Zjzfxmsp zfsp = (Zjzfxmsp) object;
这种方式强转,虽然IDEA没有报编译错误
但是运行起来就报错了
java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class cn.xxxxx.xxxxx.xxxx.models.Zjzfxmsp (java.util.LinkedHashMap is in module java.base of loader 'bootstrap'; cn.xxxxx.xxxxx.xxxx.models.Zjzfxmsp is in unnamed module of loader org.springframework.boot.loader.LaunchedURLClassLoader @728938a9)