NoClassDefFoundError JsonAutoDetect while parsing JSON object

前端 未结 5 912
忘掉有多难
忘掉有多难 2020-11-28 14:23

I am developing a webapp using Amazon\'s cloud services and I need to make use of JSON objects. How my project is set up is, I have an HTML form where the user will fill in

相关标签:
5条回答
  • 2020-11-28 14:38

    If you use maven and have all libraries in place as in my case a simple mvn clean and mvn install fixed problem.

    0 讨论(0)
  • 2020-11-28 14:43

    Or the following gradle configuration:

    compile 'com.fasterxml.jackson.core:jackson-core:2.2.2'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.2.2'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.2.2'
    
    0 讨论(0)
  • 2020-11-28 14:44

    For those who come here in the future, the answer is:

    If you've only copied jackson core and jackson databind, you need jackson annotations to use the ObjectMapper.

    For example, make sure you have something like this:

    [16:32:01]:/android-project/libs     master]$ ls -lAF
    total 2112
    -rw-r--r--@ 1 jeffamaphone  staff   33525 Jun 18 16:06 jackson-annotations-2.0.2.jar
    -rw-r--r--@ 1 jeffamaphone  staff  193693 Jun  7 16:42 jackson-core-2.0.2.jar
    -rw-r--r--@ 1 jeffamaphone  staff  847121 Jun 18 15:22 jackson-databind-2.0.2.jar
    
    0 讨论(0)
  • 2020-11-28 14:50

    To expand on @jeffamaphone's excellent answer, for maven users

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.7.3</version>
    </dependency>
    
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.7.3</version>
    </dependency>
    
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>2.7.3</version>
    </dependency>
    
    0 讨论(0)
  • 2020-11-28 14:56

    If you are/were using tomcat while developing in eclipse and got this error(maybe because you pressed republish/clean),

    a right click on the project->Maven->Update Project...

    solved this issue for me.

    In addition, i did include also the dependencies from Johan Sjöberg

    0 讨论(0)
提交回复
热议问题