knife4j 4.3默认密码
时间: 2023-11-10 15:05:35 浏览: 279
根据提供的引用内容[1]和,我们可以得出Knife4j没有默认密码。Knife4j是一种增强方案,用于解决原始Swagger页面不美观的问题,并集成了生成API文档和在线测试接口的功能。因此,Knife4j不需要密码来进行访问或使用。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
相关问题
springboot2.7整合knife4j4.3
springboot2.7整合knife4j4.3是指在Springboot 2.7版本中使用Knife4j 4.3进行API文档的生成和管理。具体步骤如下:
1.在pom.xml文件中添加Knife4j的依赖:
```
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>4.3.0</version>
</dependency>
```
2.在application.yml文件中进行配置:
```
spring:
profiles:
active: dev
application:
name: demo-knife4j-openapi3
servlet:
multipart:
max-file-size: 10MB
max-request-size: 100MB
resources:
static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
serialization:
fail-on-empty-beans: false
indent-output: true
write-dates-as-timestamps: false
write-null-map-values: false
write-empty-json-arrays: false
write-enums-using-to-string: true
http:
encoding:
charset: UTF-8
enabled: true
servlet:
session:
timeout: 30m
datasource:
url: jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
druid:
initial-size: 5
min-idle: 5
max-active: 20
test-on-borrow: true
validation-query: SELECT 1 FROM DUAL
filters: stat,wall,log4j
connection-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
jpa:
show-sql: true
hibernate:
ddl-auto: update
naming:
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
server:
port: 8080
tomcat:
uri-encoding: UTF-8
max-threads: 200
min-spare-threads: 10
max-http-header-size: 1048576
accesslog:
enabled: true
directory: logs
prefix: access_log
suffix: .log
rotate: true
pattern: common
knife4j:
title: demo-knife4j-openapi3
description: demo-knife4j-openapi3
version: 1.0.0
contact:
name: demo-knife4j-openapi3
url: http://localhost:8080/doc.html
email: demo-knife4j-openapi3@qq.com
license:
name: Apache License 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
terms-of-service-url: http://localhost:8080/doc.html
host: localhost:8080
packages: com.example.demo
```
3.在启动类上添加@EnableKnife4j注解:
```
@SpringBootApplication
@EnableKnife4j
public class DemoKnife4jOpenapi3Application {
public static void main(String[] args) {
SpringApplication.run(DemoKnife4jOpenapi3Application.class, args);
}
}
```
knife4j配置登录密码
在使用 knife4j 进行 API 文档管理时,可以通过配置登录密码来保护 API 文档的访问。下面是配置登录密码的步骤:
1. 打开 `application.properties`(或者 `application.yml`)文件,该文件一般位于项目的 `resources` 目录下。
2. 在该文件中添加以下配置:
```properties
# 开启登录密码
knife4j.login.enable=true
# 设置登录用户名
knife4j.login.username=admin
# 设置登录密码(需进行 MD5 加密)
knife4j.login.password=21232f297a57a5a743894a0e4a801fc3
```
在上述配置中,`knife4j.login.username` 配置了登录用户名,`knife4j.login.password` 配置了登录密码。请注意,`knife4j.login.password` 需要进行 MD5 加密,上面的示例是 "admin" 的 MD5 加密后的值。
3. 保存并关闭文件。
4. 重启应用程序。
配置完成后,当访问 knife4j 的 API 文档页面时,会要求输入用户名和密码才能进行访问。请确保将用户名和密码设置为安全且不易猜测的值。
阅读全文