java.lang.NoSuchFieldError: USE_DEFAULTS

java.lang.NoSuchFieldError: USE_DEFAULTS

因此,在编写和测试用于发送 SMS 的 twilio 试用代码 (Java) 时,我遇到了上述错误。这是下面的代码:

import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;

public class Sms {
    public static final String ACCOUNT_SID = "ACb519b651243a021f900be0b0d387edc9";
    public static final String AUTH_TOKEN = "I_CAN'T_SHARE";

    public static void main(String[] args) {

        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

        Message message = Message.creator(new PhoneNumber("+19916022xxx"),
                new PhoneNumber("+18082010XXX"),
                "Sent from a Twilio Trial Account").create(); // the number in the from phone number field is provided by twilio

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

}

异常堆栈跟踪:-

Exception in thread "main" java.lang.NoSuchFieldError: USE_DEFAULTS
    at com.fasterxml.jackson.annotation.JsonInclude$Value.<clinit>(JsonInclude.java:247)
    at com.fasterxml.jackson.databind.cfg.ConfigOverrides.<init>(ConfigOverrides.java:53)
    at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:564)
    at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:480)
    at com.twilio.http.TwilioRestClient.<init>(TwilioRestClient.java:31)
    at com.twilio.http.TwilioRestClient.<init>(TwilioRestClient.java:6)
    at com.twilio.http.TwilioRestClient$Builder.build(TwilioRestClient.java:104)
    at com.twilio.Twilio.getRestClient(Twilio.java:122)
    at com.twilio.base.Creator.create(Creator.java:45)
    at sms.Sms.main(Sms.java:17)

这里是 Twilio 开发人员布道者。

Twilio Java library is usable without maven you just have to ensure you have the correct dependencies. The documentation lists two ways of using the jar without a build tool.

You can either download a jar with the dependencies included, called twilio-7.x.x-with-dependencies.jar, from the maven repo.

或者,您可以通过 downloading twilio-7.x.x.jar and getting the dependencies which are listed in the projects pom.xml file.

获取无依赖项

如果有帮助请告诉我。