SAPI是一个及其精简的Restful API输出工具,诞生的背景是基于目前微服务开发接口,不少中小型项目开发人员在对接口测试时不只须要使用JUnit等进行业务接口测试,还须要对API进行自测。因此SAPI很好的解决了开发人员须要一个一个参数的往接口测试工具填写调试的反复过程。git
目前SAPI只须要开发人员引入stater后再启动类加入一行文件便可。下面咱们直接看看使用时是什么样的。github
1.在pom.xml中配置以下,其余仓库请打开连接自行选择配置spring
<dependency> <groupId>com.github.xiaour</groupId> <artifactId>xiaour.springboot.sapi.starter</artifactId> <version>1.4</version> </dependency>
2.启动类加入注解Sapi和ServletComponentScanapi
@Sapi(controllers = {"com.example.demo.ctrl","com.example.demo.ctrl2"}) @ServletComponentScan(basePackages = {"com.github.xiaour.api_scanner.servlet"}) @ComponentScan @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } }
这里说明一下Sapi的controllers是当前项目中须要被输入API的Controller路径,有多个的话配置多个便可。ServletComponentScan中的com.github.xiaour.api_scanner.servlet路径不要忽略。到这里咱们的配置几乎就所有完成了。怎么样?是否是至关简单了。浏览器
3.如何使用Sapi?springboot
启动项目后在浏览器打开地址 http://127.0.0.1:{服务端口}/{如有项目路径}/sapi 便可打开Sapi的接口列表页面;每一个接口上都有一个绿色的运行按钮,点击运行按钮就会弹出接口详细内容页面(以下图)。点击Send就能够调试接口了。
maven
好啦,各位能够当即使用sapi了,祝各位使用愉快微服务
也欢迎你们访问个人Git托管项目或Star工具