我的项目使用 Spring MVC 作为前端,使用 EJB 作为后端。当我使用 jackson 在控制器级别中序列化和反序列化 json 字符串时,下面的代码工作正常,但服务层出现错误“未找到 com.fasterxml.jackson.core.JsonParseException 的类文件”
ObjectMapper mapper = new ObjectMapper();
Object convertedObject = mapper.readValue(jsonString, class);
Run Code Online (Sandbox Code Playgroud)
我的模块 pom 文件包含依赖项。
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.3.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
创建对象后出现此错误mapper。
错误:Error:(247, 67) java: cannot access com.fasterxml.jackson.core.JsonParseException
class file for com.fasterxml.jackson.core.JsonParseException not found