发表于: 2017-11-06 23:36:34
1 749
今天完成的事情:
1. 完成手机验证
2. 学习了JVM的加载
明天计划的事情
1. 了解邮箱
2. 完结邮箱
遇到的问题:
无
收获:
1. 完成手机验证码
public String sendVerificationSMS(String phoneNumber){
inti();
String message = null;
//组装请求对象
SendSmsRequest request = new SendSmsRequest();
//使用post提交
request.setMethod(MethodType.POST);
request.setPhoneNumbers(phoneNumber);
//必填:短信签名-可在短信控制台中找到
request.setSignName(signName);
//必填:短信模板-可在短信控制台中找到
request.setTemplateCode(templateCode);
//可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
//友情提示:如果JSON中需要带换行符,请参照标准的JSON协议对换行符的要求,比如短信内容中包含\r\n的情况在JSON中需要表示成\\r\\n,否则会导致JSON在服务端解析失败
int random = ThreadLocalRandom.current().nextInt(999999);
logAliYunSmsSerImpl.info("random: " + random);
request.setTemplateParam("{\"code\":\""+ random+ "\"}");
try {
//请求失败这里会抛ClientException异常
SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);
logAliYunSmsSerImpl.info(sendSmsResponse.getCode());
if (sendSmsResponse.getCode() != null && sendSmsResponse.getCode().equals("OK")) {
logAliYunSmsSerImpl.info("OK");
message = String.valueOf(random);
redisUtil.setCacheValue(phoneNumber,message,1000*60*5);
}
} catch (ClientException ce){
ce.printStackTrace();
logAliYunSmsSerImpl.error("acsClient destory");
} catch (Exception e){
e.printStackTrace();
logAliYunSmsSerImpl.error("acsClient destory");
} finally {
destroy();
}
return message;
}
难点在于红字部分,如果出现异常阿里云是返回到sendSmsResponse里的,不会被异常抓取
难点2 在于阿里云jar在pom得配置,到目前为止,可以使用但是提示解析出错,还要再看看
<dependency>
<groupId>com.aliyuncs.dysmsapi</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/aliyun-java-sdk-dysmsapi-1.0.0.jar</systemPath>
</dependency>
明天还要研究一下
2. 如何在pom里指定jdk版本
每次重启IDEA后版本都会回到1.5,烦不胜烦索性配置到pom里,指定为1.8
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
3. 初步学习了JVM的加载
过程
加载--验证--准备--解析--初始化--使用--卸载
加载:获取类的二进制字节,将静态的存储结构作为数据结构,生成类的class对象,作为类的数据访问入口
验证:检验字节流里的信息是否符合JVM的要求,并且没有危害JVM
准备:为类成员变量和static{}分配内存和初始值。所谓初始值并不是赋予编程里值。
解析:对符号例如:public 等字符进行引用。所谓引用如同标记所在的位置。能在程序运行时候快速找到。
初始化:把值真正的赋给变量和static{}
参考资料:
进度:
任务开始时间:10.30
预计完成时间:11.6
是否有延期风险:有
第一次延期到11.7
禅道:http://task.ptteng.com/zentao/project-task-264.htm
评论