腾讯短信SDK 引用有时报 java.lang.NoSuchMethodError: org.json.JSONObject.put(Ljava/lang/String;Ljava/util/Collection;)Lorg/json/JSONObject;
腾讯短信SDK 引用有时报 java.lang.NoSuchMethodError: org.json.JSONObject.put(Ljava/lang/String;Ljava/util/Collection;)Lorg/json/JSONObject;
发送短信是会在下面红色处报上面的错:
SmsSingleSender.java
...... JSONObject body = new JSONObject() .put("tel", (new JSONObject()).put("nationcode", nationCode).put("mobile", phoneNumber)) .put("sig", SmsSenderUtil.calculateSignature(appkey, random, now, phoneNumber)) .put("tpl_id", templateId) .put("params", params) .put("sign", sign) .put("time", now) .put("extend", SmsSenderUtil.isNotEmpty(extend) ? extend : "") .put("ext", SmsSenderUtil.isNotEmpty(ext) ? ext : ""); ......
在引用项目中pom.xml加下面就解决了:
<dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20170516</version> </dependency>