迷信、愚昧和虚伪腰缠万贯,但真理一直是一个乞丐。——马丁·路德
开通服务:新手指引_短信服务-阿里云帮助中心
首先安装:
1 2 3 4 5
| <dependency> <groupId>org.dromara.sms4j</groupId> <artifactId>sms4j-spring-boot-starter</artifactId> <version>${sms4j.version}</version> </dependency>
|
然后配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| sms: config-type: yaml is-print: false blends: aliyun: supplier: alibaba access-key-id: <您的accessKey> access-key-secret: <您的accessKeySecret> request-url: dysmsapi.aliyuncs.com action: SendSms version: 2017-05-25 region-id: cn-hangzhou signature: 阿里云短信测试 template-id: SMS_XXXXXXXXX
|
使用:
1 2 3 4 5 6 7 8
| @Value("${sms.blends.aliyun.template-id}") private String templateId;
SmsBlend smsBlend = SmsFactory.getSmsBlend("aliyun"); LinkedHashMap<String, String> map = new LinkedHashMap<>(1); map.put("code", code); SmsResponse smsResponse = smsBlend.sendMessage(phone, templateId, map);
|
非常滴简单