引起:java.lang.NoClassDefFoundError:com/fasterxml/jackson/databind/JsonMappingException$Reference

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27358028/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 04:13:17  来源:igfitidea点击:

Caused by: java.lang.NoClassDefFoundError: com/fasterxml/Hymanson/databind/JsonMappingException$Reference

javaHymanson

提问by NNR

I am completely new to Java. I am trying to display JSON data, for that I have decided to go for Hymanson library. But I am getting the Error.

我对 Java 完全陌生。我正在尝试显示 JSON 数据,为此我决定使用 Hymanson 库。但我收到错误。

I am using

我在用

Hymanson-annotations-2.3.0.jar
Hymanson-core-2.4.2.jar
Hymanson-databind-2.4.2.jar

This is my Object and in this I have one dependency "tnStudentLocLog"

这是我的对象,在此我有一个依赖项“tnStudentLocLog”

public class Student implements java.io.Serializable, WorkItem {

    private int studentId;
    private Date date;
    private Date startTime;
    private Date endtime;
    private int room;
    private Set tnStudentLocLog;

    public Student() {
    }

    public Student(int studentId,Date date, int room, Date startTime, Date endtime) {
        this.studentId = studentId;
        this.date = date;
        this.room = room;
        this.startTime = startTime;
        this.endtime = endtime;
    }
}

UserController class:

用户控制器类:

 @Controller
@RequestMapping(value="/students")
public class StudentController {


    private static Logger logger = Logger.getLogger( StudentController.class);


    private StudentManagerDelegate studentDelegate;  


    public StudentController() throws Exception
    {
        studentDelegate= new StudentManagerDelegate(ServiceType.LOCAL);
    }
    /********* GET ALL STUDENTS  ************/
    @RequestMapping(method=RequestMethod.GET)
    @ResponseStatus(HttpStatus.OK)
    public @ResponseBody SuccessResponse<List<Student>> getAllStudents() throws Exception {
        Map<String,List<Student>> studentsMap = new HashMap<String,List<Student>>();
        SuccessResponse<List<Student>> resp = new SuccessResponse<List<Student>>();
        resp.list = studentDelegate.load();
        return resp;
    }

Here, I am getting the correct result. But, "studentId":2 is looping itself like below

在这里,我得到了正确的结果。但是,“studentId”:2 像下面这样循环自己

     {"max":"30","list":[{"studentId":2,"date":1339327730000,"startTime":1339327806000,"endtime":1339329470000,"room":0,"tnStudentLocLog":
[{"id":"studentId":2,"inTime":1339327872000},"sequenceId":2,"outTime":1339327967000,"Student":{"studentId":2,"date":1339327730000,"startTime":1339327806000,"endtime":1339329470000,"tnStudentLocLog":[{"id":{"studentId":2,"room":10,"inTime":1339327872000},"sequenceId":2,"outTime":1339327967000,"Student":{"studentId":2,"date":1339327730000,"startTime":1339327806000,"endtime":1339329470000,"tnStudentLocLog":[{"id":.......

But, In the URL when I enter "/students/4". It is displaying correctly. I don't know what exactly happening. I saw many posts, they are changing versions of Hymanson core, annotations. But, that is not working in my case.

但是,在我输入“/students/4”时的 URL 中。它显示正确。我不知道究竟发生了什么。我看到了很多帖子,他们正在更改 Hymanson 核心、注释的版本。但是,这在我的情况下不起作用。

Thanks in advance for your help.

在此先感谢您的帮助。

回答by Duston

Welcome to java. One of the first things you'll need to learn when using Java is how to set up and use the CLASSPATH. The "Class Not Found" error means one or more of your jar files are not in the classpath. Java does not implicitly look anywhere (not even the same subdirectory where your classes are) for .jar files. You have to tell it where to look. How do you set up the CLASSPATH? That depends on your platform (Windows, Linux, IIS, Apache, Tomcat, Bluejay, Eclipse, etc...) Learn that well, you will prevent many a headache.

欢迎来到爪哇。使用 Java 时需要学习的第一件事是如何设置和使用 CLASSPATH。“未找到类”错误意味着您的一个或多个 jar 文件不在类路径中。Java 不会在任何地方(甚至不是您的类所在的子目录)隐式查找 .jar 文件。你必须告诉它在哪里看。你如何设置CLASSPATH?这取决于您的平台(Windows、Linux、IIS、Apache、Tomcat、Bluejay、Eclipse 等...) 好好学习,您将避免许多头痛。

回答by gprathour

You are missing a jar file which would contain the needed class which is com.fasterxml.Hymanson.databind.JsonMappingException

您缺少一个 jar 文件,该文件将包含所需的类 com.fasterxml.Hymanson.databind.JsonMappingException

You can download it from hereand include in your Class Path.

你可以从这里下载它并包含在你的类路径中。

回答by Karthi Krazz

Check do you have any cyclic dependency, if you have cyclic dependency you can ignore it by @JsonIgnore Check here for cyclic dependency

检查你是否有任何循环依赖,如果你有循环依赖,你可以通过@JsonIgnore 忽略它在这里检查循环依赖