json – 无法使用带有参数的构造函数NO_CONSTRUCTOR在MongoDB中实例化com.fasterxml.jackson.databind.node.ObjectNode

enter image description here我正在使用JsonNode从任何类型的jason格式获取数据并将其存储到mongoDb
但是从mongoDB获取数据时,它会抛出错误,如下所示.

无法使用带参数的构造函数NO_CONSTRUCTOR实例化com.fasterxml.jackson.databind.node.ObjectNode

下面是我的域类

public class Profiler {

 @Id
 private String id;

@Field("email")
private String email;

@Field("profiler")
private Map<String,JsonNode> profiler;

public String getEmail() {
    return email;
}
public void setEmail(String email) {
    this.email = email;
}
public Map<String, JsonNode> getProfiler() {
    return profiler;
}
public void setProfiler(Map<String, JsonNode> profiler) {
    this.profiler = profiler;
}
public Profiler(String email,Map<String,JsonNode> profiler){
    this.email=email;
    this.profiler = profiler;
}
@JsonCreator
public Profiler(@JsonProperty("_id")String id,@JsonProperty("email")String email,@JsonProperty("profiler")Map<String,JsonNode> profiler){
    this.id=id;
    this.email=email;
    this.profiler = profiler;
}
public Profiler(String id){
    this.id=id;
}
public Profiler(Map<String,JsonNode> profiler){
    this.profiler = profiler;
}
public Profiler(){

}

}



public interface ProfilerRepository extends MongoRepository<Profiler, String>{
public Profiler findOneByEmail(String email);
}

我的控制器调用如下,我在这一行得到错误.

Profiler profile=profileService.findOneByEmail(email);
最佳答案
我做了这些更改并按预期工作.

Map<String, Object> profile;

转载注明原文:json – 无法使用带有参数的构造函数NO_CONSTRUCTOR在MongoDB中实例化com.fasterxml.jackson.databind.node.ObjectNode - 代码日志