java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/JsonMappingException [英] java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/JsonMappingException

查看:106
本文介绍了java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/JsonMappingException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试按照 Twilio 教程通过 Java 代码发送短信 此处 但我在 收到 java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/JsonMappingException第 13 行 在我的代码中,我正在编写 Service service = Service.creator("My First Messaging Service").create();

I am try to send a text message via a Java Code following Twilio tutorial here but i am getting java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/JsonMappingException at Line 13 in my code where i am writing Service service = Service.creator("My First Messaging Service").create();

我尝试关注此线程并添加了所有必需的依赖项,但我不知道在代码中的何处使用 @JsonIgnore引起:java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/JsonMappingException$Reference

I tried following this thread and have added all the required dependencies but i don't know where to use @JsonIgnore in my code Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/JsonMappingException$Reference

我该如何解决这个问题?请帮我解决这个问题.这是我的java代码

How can i resolve this? Please help me how to fix this. Here's my java code

import com.twilio.Twilio;
import com.twilio.rest.messaging.v1.Service;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.core.*;
public class SMSOTP 
{
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");
    public static void main(String[] args) 
    {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Service service = Service.creator("My First Messaging Service").create();

        System.out.println(service.getSid());
    }
}

推荐答案

对于任何来到这里寻找解决方案的人来说,这都是一个严重的依赖问题.我在我的项目中手动添加了 3 个 jackson API(注释、数据绑定和核心),这就是问题所在.它实际上需要更多.

To anyone who came here looking for a solution, it is seriously a dependency problem. I had 3 jackson APIs' (annotations, databind and core) added manually to my project and that was the issue. It actually required more then that.

所以我所做的是通过遵循 Convert Existing Eclipse Project 切换到 Maven 项目到 Maven 项目 和 pom.xml,在 <builds> 中,我复制粘贴了 twilio 从这里开始工作所需的所有 <plugins>href="https://github.com/twilio/twilio-java/blob/main/pom.xml" rel="nofollow noreferrer">https://github.com/twilio/twilio-java/blob/main/pom.xml

So what i did is switched to Maven project by following Convert Existing Eclipse Project to Maven Project and in pom.xml, in <builds> i copy pasted all the <plugins> that twilio required to work from here https://github.com/twilio/twilio-java/blob/main/pom.xml

感谢@MichałZiober 的建议,它最终奏效了.

Thanks to @MichałZiober for the suggestion, it eventually worked.

希望这可以帮助任何人免于挠头数小时:) 祝你好运!

Hope this helps anyone from scratching their heads for hours :) Goodluck!

这篇关于java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/JsonMappingException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆