怎么配置springboot3和knife4j
时间: 2024-06-10 19:06:15 浏览: 92
Springboot使用Knife4j
对于配置springboot3和knife4j,可以按照以下步骤进行:
1. 将以下依赖添加到pom.xml文件中:
```xml
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>3.0.2</version>
<scope>compile</scope>
</dependency>
```
2. 在application.yml文件中添加以下配置:
```yaml
knife4j:
documentation:
title: XXX API接口文档
version: 1.0.0
description: XXX API接口文档
contact:
name: XXX
url: https://www.xxx.com
email: xxx@xxx.com
basic:
enable: true
```
3. 在启动类上添加@EnableKnife4j注解。如下所示:
```java
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
import springfox.documentation.swagger2.annotations.EnableSwaggerBootstrapUI;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebFlux;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebFlux;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication
@EnableSwagger2
@EnableSwagger2WebMvc
@EnableSwaggerBootstrapUI
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
```
以上就是配置springboot3和knife4j的步骤,希望能对你有所帮助。
阅读全文