1.引入依賴
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
<version>4.3.0</version>
</dependency>
2.配置文件
knife4j:
# 開啟增強(qiáng)配置
enable: true
# 是否關(guān)閉調(diào)試頁面,如果為true铲汪,無法頁面調(diào)試接口,生產(chǎn)環(huán)境開啟
production: false
# 開啟Swagger的Basic認(rèn)證功能,默認(rèn)是false
basic:
enable: false
# Basic認(rèn)證用戶名
username: test
# Basic認(rèn)證密碼
password: 123
3.springsecurity放行相關(guān)接口
auth.requestMatchers("/auth/",
"/doc.html",
"/webjars/",
"/img.icons/",
"v3/api-docs",
"/v3/api-docs/swagger-config",
"/v3/api-docs/",
"/swagger-ui/index.html",
"swagger-resources/**",
"/v2/api-docs"
).permitAll()