spring cloud knife4j 配置
时间: 2023-11-21 11:55:32 浏览: 90
以下是Spring Cloud Knife4j的配置步骤:
1.在pom.xml文件中添加以下依赖:
```xml
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>${latest.version}</version>
</dependency>
```
2.在application.yml文件中添加以下配置:
```yaml
knife4j:
swagger-ui:
enabled: true # 是否开启swagger-ui
path: /doc.html # swagger-ui访问路径
api-docs:
enabled: true # 是否开启api-docs
path: /v2/api-docs # api-docs访问路径
```
3.在启动类上添加@EnableKnife4j注解,开启Knife4j功能。
```java
@SpringBootApplication
@EnableKnife4j
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
```
4.访问http://localhost:port/doc.html即可查看Swagger文档。
阅读全文