[英]In Spring Data Rest, Swagger2 configuration issue by using profile
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-data-rest</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
@Profile({"dev-test", "local-test"})
@Configuration
@EnableSwagger2WebMvc
public class SwaggerConfig {
@Bean
public Docket documentation() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(s -> s.matches("/_api/.*"))
.build();
}
}
當profile
不是local-test或dev-test 時會發生此錯誤。
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 4 of constructor in springfox.documentation.spring.data.rest.EntityServicesProvider required a bean of type 'com.fasterxml.classmate.TypeResolver' that could not be found.
Action:
Consider defining a bean of type 'com.fasterxml.classmate.TypeResolver' in your configuration.
嗨,我正在使用Swagger3.0
和 Spring 數據 Rest。
這是我引用的鏈接。 https://stackoverflow.com/a/46458135/10345277
我正在做的是嘗試通過配置文件打開或關閉 Swagger。
但是,與上面的鏈接不同,我使用 SDR 和springfox.documentation.spring.data.rest
拋出錯誤。
有解決辦法嗎?
我的swagger3.0很好,像這樣:
@ConditionalOnClass(value = {Swagger.class})
@Profile({"dev", "test"})
@Configuration
@EnableSwagger2
public class SwaggerConfig {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("your base package"))
.paths(PathSelectors.any())
.build();
}
在我的例子中 - 使用 io.springfox:springfox-swagger2:2.9.2 和 io.springfox:springfox-swagger-ui:2.9.2 - 因為我忘記添加 @EnableSwagger2 到我的 @Configuration class 觸發了這個錯誤戰爭
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.