Spring Boot 2集成knife4j
Knife4j
的前身是swagger-bootstrap-ui
,前身swagger-bootstrap-ui
是一个纯swagger-ui
的ui
皮肤项目一开始项目初衷是为了写一个增强版本的swagger的前端ui,但是随着项目的发展,面对越来越多的个性化需求,不得不编写后端Java代码以满足新的需求,在
swagger-bootstrap-ui
的1.8.5~1.9.6版本之间,采用的是后端Java代码和Ui都混合在一个Jar包里面的方式提供给开发者使用.这种方式虽说对于集成swagger来说很方便,只需要引入jar包即可,但是在微服务架构下显得有些臃肿。
引入依赖
<!-- Spring Boot 集成 knife4j swagger -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>
yml配置文件
knife4j:
enable: true
openapi:
title: "内容管理系统"
description: "内容系统管理系统对课程相关信息进行业务管理数据"
# aaa"
email: xxxxxx@outlook.com
concat: bgu
url: https://docs.xxxxxx.com
version: v1.0.0
license: Apache 2.0
license-url: "https://xxxxxx.com/"
terms-of-service-url: "https://xxxxxx.com/"
group:
test1:
group-name: "内容管理系统"
api-rule: package
api-rule-resources:
- com.xxx.content
# basic:
# password: admin
# username: admin
报错
Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
加@EnableWebMvc注解或
spring:
mvc:
pathmatch: #Swagger相关
matching-strategy: ant_path_matcher