Spring Boot 2.0整合Swagger2.8
Swagger简介
Swagger是一系列RESTful API 的工具, 通过Swagger可以获得项目的一种交互式文档, 客户端SDK的自动生成等功能. 从 Swagger Github 的官方主页摘录:
The goal of Swagger™ is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection.
软件版本
- JDK1.8
- spring boot 2.0
- Swagger 2.8
[一]依赖引入
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
【添加配置类】
package com.lx.soilparent.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation