Jac*_*ack 4 java swagger spring-boot springfox
我正在尝试将 Swagger 添加到我的项目https://www.baeldung.com/swagger-2-documentation-for-spring-rest-api
我在上面的教程中得到了 4.3 段落,当我运行我的应用程序时,我遇到了一些错误。
我将其添加到我的pom.xml:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
另外,我添加了配置类:
@Configuration
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行我的项目时,我得到:
小智 7
我从 pom.xml 中删除了以下依赖项
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
对我来说它有效
| 归档时间: |
|
| 查看次数: |
18205 次 |
| 最近记录: |