<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
不是本地测试或 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.
嗨,我在Spring Data Rest中使用Swagger3.0
。
这是我引用的链接。 https://stackoverflow.com/a/46458135/10345277
我正在做的是尝试通过个人资料打开或关闭Swagger。
但是,与上面的链接不同,我使用SDR,springfox.documentation.spring.data.rest
会引发错误。
有解决方案吗?
答案 0 :(得分:0)
我的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();
}