PS:新手尝鲜,第一次编写,不喜勿喷,欢迎指正。
<!--可先尝试 版本控制 不行再用下面方法-->
<!--可先尝试 版本控制-->
<properties>
<jackson.version>2.8.9</jackson.version>
</properties>
使用IDEA 启动一直正常,但在部署到服务器出现问题
java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/exc/InvalidDefinitionException
java.lang.NoClassDefFoundError: Could not initialize class com.fasterxml.jackson.databind.ObjectMapper
先后参考:
https://blog.csdn.net/baidu_38609744/article/details/82725742
https://blog.csdn.net/qq_41520636/article/details/84380457
https://www.cnblogs.com/exmyth/p/5136695.html
未能直接解决问题,了解到可能是springboot 2.1.4 版本问题,于是进一步尝试。
于是查看自己包依赖 注意 jackson 版本:
然后与maven仓库版本对比,发现依赖jackson版本为2.9.8 最新为2.9.9:
于是修改依赖
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.module/jackson-module-parameter-names -->
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-parameter-names</artifactId>
<version>2.9.8</version>
</dependency>
打包后部署成功。
此时依赖关系对比
目前就这样处理(还要处理其他事情,以后有机会再找更好的方法解决),有更好方法,还望分享。