我从githud存储库中提取最新代码后得到以下内容.
为org.codehaus.mo构建有效模型时遇到的问题
错误的完整描述如下.
在构建有效模型时遇到了1个问题
org.codehaus.mojo:aspectj-maven-plugin:1.8
[ERROR] 'dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${toolsjarSystemPath} @
Run Code Online (Sandbox Code Playgroud)
我使用的是java1.8和sts 3.6.4
我正在使用杰克逊2.x进行序列化和反序列化。我将objectMapper注册到afterBurner模块,并配置了对象映射器以忽略未知属性
objectMapper.registerModule(new AfterBurnerModule());
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
Run Code Online (Sandbox Code Playgroud)
但是,当它尝试序列化对象时,它会失败,并发现属性错误的未知字段
java对象也用@JsonIgnoreProperties注释(ignoreUnknown = true)
有人可以帮助我了解可能出了什么问题吗
以下是实用程序类
package example;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.AnnotationIntrospector;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
import com.fasterxml.jackson.module.afterburner.AfterburnerModule;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
public final class Util {
private static ObjectMapper objectMapper;
static {
objectMapper = new ObjectMapper();
objectMapper.registerModule(new AfterburnerModule());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
objectMapper.setDateFormat(sdf);
objectMapper.setAnnotationIntrospector(AnnotationIntrospector.pair(new JaxbAnnotationIntrospector(objectMapper.getTypeFactory()), new JacksonAnnotationIntrospector()));
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.setSerializationInclusion(Include.NON_NULL);
}
private Util() {
}
public static <T> T convertToObject(String jsonString,Class<T> classType){
T obj = null;
try {
obj = objectMapper.readValue(jsonString, classType);
} …Run Code Online (Sandbox Code Playgroud)