1.导入依赖
<!--阿里云短信依赖 --> <dependency> <groupId>com.aliyun</groupId> <artifactId>aliyun-java-sdk-core</artifactId> <version>4.6.0</version> </dependency> <dependency> <groupId>com.aliyun</groupId> <artifactId>aliyun-java-sdk-dysmsapi</artifactId> <version>2.2.1</version> </dependency>
2.创建类
package com.tm.utils; import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.IAcsClient; import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.exceptions.ServerException; import com.aliyuncs.profile.DefaultProfile; import com.google.gson.Gson; import com.aliyuncs.dysmsapi.model.v20170525.*; public class SendSms { public static void main(String[] args) { DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "密钥", "密钥"); /** use STS Token DefaultProfile p