微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

enter image description here

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

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

下面是我的域类@H_502_3@

@H_502_3@

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);
}

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

@H_502_3@

Profiler profile=profileService.findOneByEmail(email);
@H_404_22@最佳答案:@H_502_3@

我做了这些更改并按预期工作.@H_502_3@

@H_502_3@

Map<String, Object> profile;

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐