1、创建父子工程
|– or-statistic-service
|–|– statistic-interface
|–|– statistic-service
①statistic-interface
项目为普通的maven项目,可以封装接口,让其他项目进行jar的引用
//实体类入参
public class ScanQrInfoReq {
private String groupID;
private String shopID;
}
//SDK中的方法
@Slf4j
public class StatisticService {
public static void logScanQrInfo(ScanQrInfoReq scanQrInfoReq) {
log.info("---sjn---:" + scanQrInfoReq.toString());
System.out.println("---sjn---Hello World!---");
}
}
//pom文件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>or-statistic-service</artifactId>
<groupId>com.hahaha.or</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>statistic-interface</artifactId>
<name>statistic-interface</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.6</version>
</dependency>
</dependencies>
</project>
②statistic-service
项目为spring boot项目,可以继承interface项目中的接口,被SDK调用执行
2、项目install
使用mvn命令:mvn clean install打包安装
install的时候需要将父工程也要install到本地仓库
3、使用SDK
1)项目引入jar包
<dependency>
<groupId>com.hahaha.or</groupId>
<artifactId>statistic-interface</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
2)方法中直接进行调用
public class ScanQrController {
public void scanQrInfo() {
StatisticService.logScanQrInfo(new ScanQrInfoReq("111","222"));
}
}