1、先建一个Springboot项目
2、pom依赖导入
不加以下配置这个使用@EnableSwagger2注解时会报错
Unable to infer base url. This is common when using dynamic servlet registration or when the API is behind an API Gateway. The base url is the root of where all the swagger resources are served…
导入依赖
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
3、建一个controller
4、在启动类加
5、启动、访问
http://localhost:8080/swagger-ui.html