Swagger 是一款RESTFUL接口的文档在线自动生成+功能测试功能软件,它的源码地址在github上,源码地址:传送门
然后自己在github 上找到一个修改swaggerUI的依赖,相比之下还是比原始的比较好看一点。传送门
具体实现步骤:
- 在pom.xml文件中添加依赖
<!--github上找到swaggerUI-->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>1.8.4</version>
</dependency>
<dependency>
<groupId>com.spring4all</groupId>
<artifactId>swagger-spring-boot-starter</artifactId>
<version>1.8.0.RELEASE</version>
</dependency>
- 在主类添加注解@EnableSwagger2Doc
@EnableSwagger2Doc
@SpringBootApplication
public class SpringDataJpaApplication {
public static void main(String[] args) {
SpringApplication.run(SpringDataJpaApplication.class, args);
}
}
- 运行主类,在网页中输入http://localhost:8080/doc.html即可自动查找RESTFUL风格的接口运行截图