Introduce pom dependencies:
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.7.0</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.7.0</version> </dependency>
Go to GitHub https://github.com/swagger-api/swagger-ui to download the project, copy the dist directory and put it directly in the resource path.
index.html is the api page
Then add the annotation @EnableSwagger2 to the Spring Boot startup class
@SpringBootApplication @EnableSwagger2 public class NeteaseApplication { public static void main(String[] args) { SpringApplication.run(NeteaseApplication.class, args); } }
Api address: http://localhost:8080/api/index (the address is determined by the stored resource path folder)
Api-json:http://localhost:8080/v2/api-docs
Swagger2 common annotations: https://blog.csdn.net/u014231523/article/details/76522486