发表于: 2017-07-14 23:32:59

1 1045


今天


1. 把项目重新搭了一遍,所有的类(除了模型类)都由Spring管理,重写了Service层,消灭了重复代码。


2. 了解了什么是第三方API,注册了云通讯,加载了jar包,加载了测试类,进行了测试,短信要充500块钱才能用,语音验证不用充钱,就试了语音验证,虽然返回了成功的信息回来,但是手机上没有收到语音电话验证码,不知道怎么回事,客服没人理。

public static void main(String[] args) {
HashMap<String, Object> result = null;
   CCPRestSDK restAPI = new CCPRestSDK();
   restAPI.init("app.cloopen.com", "8883");
   // 初始化服务器地址和端口,生产环境配置成app.cloopen.com,端口是8883.
   restAPI.setAccount("8aaf07085d106c7f015d40554e83149e", "b24cd340c8fc466bbfa025788b919943");
   // 初始化主账号名称和主账号令牌,登陆云通讯网站后,可在"控制台-应用"中看到开发者主账号ACCOUNT SID和
   //主账号令牌AUTH TOKEN。
   restAPI.setAppId("8aaf07085d106c7f015d40554fdb14a4");
   // 初始化应用ID,如果是在沙盒环境开发,
   //请配置"控制台-应用-测试DEMO"中的APPID。如切换到生产环境,请使用自己创建应用的APPID
   result = restAPI.voiceVerify("123456", "18601123412", null, "3",
           null, null, null);
   System.out.println("SDKTestVoiceVerify result=" + result);
   if ("000000".equals(result.get("statusCode"))) {
       //正常返回输出data包体信息(map)
       HashMap<String, Object> data = (HashMap<String, Object>) result.get("data");
       Set<String> keySet = data.keySet();
       for (String key : keySet) {
       Object object = data.get(key);
       System.out.println(key + " = " + object);
   }
} else {
//异常返回输出错误码和错误信息
       System.out.println("错误码=" + result.get("statusCode") + " 错误信息= " + result.get("statusMsg"));
   }
}

运行后返回了000000,意思是成功了,但是收不到电话验证码。

SDKTestVoiceVerify result={data={VoiceVerify={callSid=170714202538409000010124004dccd8, dateCreated=2017-07-14 20:25:38, orderId=CM1012420170714202538517465}}, statusCode=000000}

VoiceVerify = {callSid=170714202538409000010124004dccd8, dateCreated=2017-07-14 20:25:38, orderId=CM1012420170714202538517465}

Process finished with exit code 0

3. 学会了几种导入第三方包的方法(IDEA)


第一是用IDEA的界面导入,方法是点右上角的Project Structure,点Modules,点加号,选择Jar包。这种方法虽然简单,但是如果用Maven的话是行不通的,因为Maven编译的时候读不到IDEA加载的Jar包,所以根本无法编译,但是在IDEA中是不报错的。


第二种方法是Maven官方网站上的方法:


Although rarely, but sometimes you will have 3rd party JARs that you need to put in your local repository for use in your builds, since they don't exist in any public repository like Maven Central. The JARs must be placed in the local repository in the correct place in order for it to be correctly picked up by Apache Maven. To make this easier, and less error prone, we have provide a goal in the maven-install-plugin which should make this relatively painless. To install a JAR in the local repository use the following command:
  1. mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
  2.    -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
If there's a pom-file as well, you can install it with the following command:
  1. mvn install:install-file -Dfile=<path-to-file> -DpomFile=<path-to-pomfile>
With version 2.5 of the maven-install-plugin it gets even better. If the JAR was built by Apache Maven, it'll contain a pom.xml in a subfolder of the META-INF directory, which will be read by default. In that case, all you need to do is:
  1. mvn install:install-file -Dfile=<path-to-file>

这种方法是把指定的Jar包加入到本地的仓库中,自己指定ID号和版本,自己再去加载,这种方法有一个缺点,就是只能打包好了再部署,先部署就打包不了了,因为服务器没有这个包。


第三种方法是在一个帖子里找到的:

Create a new folder, let's say local-maven-repo at the root of your Maven project.
Just add a local repo inside your <project> of your pom.xml:
<repositories>
    <repository>
        <id>local-maven-repo</id>
        <url>file:///${project.basedir}/local-maven-repo</url>
    </repository>
</repositories>
Then for each external jar you want to install, go at the root of your project and execute:
mvn deploy:deploy-file -DgroupId=com.cloopen.rest -DartifactId=sdk -Dversion=1.0 -Durl=file:./libs/ -DrepositoryId=libs -DupdateReleaseInfo=true -Dfile=/Users/air/Desktop/CCP_REST_SDK_JAVA_v2.7r.jar

先在pom.xml 中加入一个本地仓库,就是项目根目录下的新建一个libs文件夹,然后用下面的命令把Jar包导入项目中,再在项目中添加依赖就可以了,但也比较麻烦。


总之,没什么太好的方法。


问题:无


总结:无


返回列表 返回列表
评论

    分享到