在springboot项目中无侵入的添加swaggerui
在springboot项目中无侵入的添加swaggerui
1、在pom.xml中添加swaggerui相关依赖
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.5.0</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.5.0</version> </dependency>
2、在项目的config文件夹下添加swaggerconfig类
package com.demo.config; import org.springframework.context.annotation.Configuration; import springfox.documentation.swagger2.annotations.EnableSwagger2; @Configuration @EnableSwagger2 public class SwaggerConfig { }
3、添加一个controller服务类
4、运行后在浏览器输入:http://localhost:8002/swagger-ui.html