SDK也跟springboot-starter是一个道理,通过maven导入实现
存放的目录在maven本地仓库中,如果要实现远程调用,需要去注册maven仓库账号或者使用jar包
Starter开发流程
初始化SpringBoot项目模版,环境依赖(一定要移除build):
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>l
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
编写配置类(启动类)
@Configuration
@ConfigurationProperties("api.client")
@Data
@ComponentScan
public class ApiClientConfig {
private String accessKey;
private String secretKey;
@Bean
public ApiClient ApiClient() {
return new ApiClient(accessKey, secretKey);
}
}
注册配置类
resources/META-INF/spring.factories
# spring boot starter
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.alex.apiclientsdk.ApiClientConfig
mvn install 打包为本地依赖
创建新项目(复用server项目)、测试