<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();
}
}
当配置文件
不是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 Data Rest。
这是我引用的链接。 https://stackoverflow.com/a/46458135/10345277
我正在做的是尝试通过配置文件打开或关闭 Swagger。
但是,与上面的链接不同,我使用 SDR 并且 springfox.documentation.spring.data.rest
抛出错误。
有解决办法吗?
最佳答案
就我而言 - 使用 io.springfox:springfox-swagger2:2.9.2 和 io.springfox:springfox-swagger-ui:2.9.2 - 触发此错误 war 是因为我忘记将 @EnableSwagger2 添加到我的 @Configuration 类
关于java - 在Spring Data Rest中,使用profile的Swagger2配置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56288661/