ali-tools

Ali Tools project for Spring Boot

License

License

GroupId

GroupId

cn.happyloves
ArtifactId

ArtifactId

ali-tools
Last Version

Last Version

0.0.5
Release Date

Release Date

Type

Type

jar
Description

Description

ali-tools
Ali Tools project for Spring Boot
Project URL

Project URL

https://github.com/452425952/ali-tools
Project Organization

Project Organization

Pivotal Software, Inc.
Source Code Management

Source Code Management

https://github.com/452425952/ali-tools

Download ali-tools

How to add to project

<!-- https://jarcasting.com/artifacts/cn.happyloves/ali-tools/ -->
<dependency>
    <groupId>cn.happyloves</groupId>
    <artifactId>ali-tools</artifactId>
    <version>0.0.5</version>
</dependency>
// https://jarcasting.com/artifacts/cn.happyloves/ali-tools/
implementation 'cn.happyloves:ali-tools:0.0.5'
// https://jarcasting.com/artifacts/cn.happyloves/ali-tools/
implementation ("cn.happyloves:ali-tools:0.0.5")
'cn.happyloves:ali-tools:jar:0.0.5'
<dependency org="cn.happyloves" name="ali-tools" rev="0.0.5">
  <artifact name="ali-tools" type="jar" />
</dependency>
@Grapes(
@Grab(group='cn.happyloves', module='ali-tools', version='0.0.5')
)
libraryDependencies += "cn.happyloves" % "ali-tools" % "0.0.5"
[cn.happyloves/ali-tools "0.0.5"]

Dependencies

compile (5)

Group / Artifact Type Version
org.springframework.boot : spring-boot-configuration-processor Optional jar 2.3.0.RELEASE
org.springframework.boot : spring-boot-autoconfigure jar 2.3.0.RELEASE
com.alibaba.cloud : aliyun-oss-spring-boot-starter jar
com.alibaba.cloud : aliyun-sms-spring-boot-starter jar
org.projectlombok : lombok Optional jar 1.18.12

provided (1)

Group / Artifact Type Version
javax.servlet : javax.servlet-api jar 4.0.1

Project Modules

There are no modules declared in this project.

ali-tools

ali-tools目前支持

OSS文件存储,文件上传、删除文件、批量删除、查看文件列表
SMS短信服务

使用教程:

第一步:添加依赖

<dependency>
    <groupId>cn.happyloves</groupId>
    <artifactId>ali-tools</artifactId>
    <version>${ali.tools.version}</version>
</dependency>

第二步:配置属性

ali-tools:
  oss:
    accessKeyId: ${accessKeyId}
    accessKeySecret: ${accessKeySecret}
    endpoint: oss-cn-shanghai.aliyuncs.com
    bucketName: happyloves
#    HTTPProtocol: https #默认为http
#    home: 默认为:upload
# 示例:
#oss (https://bucketNmae.oss-cn-beijing.aliyuncs.com/upload/xxx.xxx)
#cdn (https://xxx.xxx.com/upload/xxx.xxx)
#    cdn: 不传则为oss域名,反之为cdn
  sms:
    accessKeyId: ${ali-tools.oss.accessKeyId}
    accessKeySecret: ${ali-tools.oss.accessKeySecret}
    singleName:
    templateCode:

第三步:添加注解

@EnableAliToolsOss//启用OSS
@EnableAliToolsSms//启用SMS
@SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

第四步:如何使用

@SpringBootTest
class DemoApplicationTests {

    @Autowired
    private OSSClient ossClient;
    @Autowired
    private OssProperties ossProperties;

    @Test
    void oss() {
        File file = new File("C:\\Users\\ZC\\OneDrive\\圖片\\001.jpg");
        FileInputStream fileInputStream = new FileInputStream(file);

        String upload = OssUtils.OssUpload.upload(ossClient, ossProperties, "test2.png", fileInputStream);
        System.out.printf(upload);
    }

    @Autowired
    private IAcsClient smsClient;
    @Autowired
    private SmsProperties smsProperties;

    @Test
    void sms() {
       SmsUtils.SendSmsRequest par = new SmsUtils.SendSmsRequest();
       par.setPhoneNumber("手机号");
       par.setSignName("签名");
       par.setTemplateCode("模板CODE");
       par.setTemplateParam("{'name':'模板字符串JSON格式'}");
       SmsUtils.sendSms(smsClient, smsProperties, par);
    }


}

开发工具使用JetBrains的IDEA

Versions

Version
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1