1,引入相关jar包:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.1</version>
</dependency>
<!-- swagger自带的界面 -->
<!-- <dependency> -->
<!-- <groupId>io.springfox</groupId> -->
<!-- <artifactId>springfox-swagger-ui</artifactId> -->
<!-- <version>2.6.1</version> -->
<!-- </dependency> -->
<!-- bootstrap开源的界面 -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>1.8.1</version>
</dependency>
2,新建配置类:
package com.example.swagger.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import