1.引入依赖
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
<version>4.3.0</version>
</dependency>
2.配置文件
knife4j:
# 开启增强配置
enable: true
# 是否关闭调试页面,如果为true,无法页面调试接口,生产环境开启
production: false
# 开启Swagger的Basic认证功能,默认是false
basic:
enable: false
# Basic认证用户名
username: test
# Basic认证密码
password: 123
3.springsecurity放行相关接口
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()