添加 项目依赖
点击查看代码
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
添加一个配置,要不然会报如下错误:
Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[spring-context-5.3.21.jar:5.3.21]
所以要在application.yml中添加:
spring: mvc: pathmatch: matching-strategy: ant_path_matcher
启动工程就可以了
访问地址是: UI : http://localhost:8080/swagger-ui/index.html#/
doc :http://localhost:8080/v3/api-docs