springboot实现短信验证码发送功能
话不多说,上代码,直接是最简代码
1.pom.xml文件需要导入的依赖:
<!--阿里云短信服务-->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.61</version>
</dependency>
2.SmsService类
package ydj.plugins.pojo;
public interface SmsService {
boolean sendSms(String phoneNumber); // 接收验证码手机号
}
3.SmsServiceImpl 实现类
package ydj.plugins.pojo;
import com.alibaba.fastjson.JSONObject;
import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs