Проблема:
Для поля typeResolver в com.demo.MyApplication требуется компонент типа 'com.faster xml .classmate.TypeResolver', который не может быть найден.
Точка внедрения имеет следующие аннотации:
@org.springframework.beans.factory.annotation.Autowired (обязательно = true)
Действие:
Рассмотрим определение компонента типа 'com.faster xml .classmate.TypeResolver' в вашей конфигурации.
Мой код:
@SpringBootApplication
@EnableSwagger2WebMvc
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
@Autowired
private TypeResolver typeResolver;
@Bean
public Docket petApi() {
final List<ResponseMessage> globalResponses = Arrays.asList(
new ResponseMessageBuilder()
.code(200)
.message("OK")
.build(),
new ResponseMessageBuilder()
.code(400)
.message("Bad Request")
.build(),
new ResponseMessageBuilder()
.code(500)
.message("Internal Error")
.build());
final ApiInfo apiInfo = new ApiInfo("Bills & Payments REST API", "It is B&P Microservice",
"1.0.0-RC1", "", new Contact("iTac Team", "", "team@cogniphi.com"), "", "", Collections.emptyList());
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.demo.controller")) //RequestHandlerSelectors.any()
.paths(PathSelectors.any())
.build()
.apiInfo(apiInfo)
.pathMapping("/")
.directModelSubstitute(LocalDate.class, String.class)
.genericModelSubstitutes(ResponseEntity.class)
.alternateTypeRules(
newRule(typeResolver.resolve(DeferredResult.class,
typeResolver.resolve(ResponseEntity.class, WildcardType.class)),
typeResolver.resolve(WildcardType.class)))
.useDefaultResponseMessages(false)
.globalResponseMessage(RequestMethod.GET, globalResponses)
.globalResponseMessage(RequestMethod.POST, globalResponses)
.globalResponseMessage(RequestMethod.DELETE, globalResponses)
.globalResponseMessage(RequestMethod.PATCH, globalResponses)
//.securitySchemes(singletonList(apiKey()))
//.securityContexts(singletonList(securityContext()))
.enableUrlTemplating(true)
.globalOperationParameters(
singletonList(new ParameterBuilder()
.name("someGlobalParameter")
.description("Description of someGlobalParameter")
.modelRef(new ModelRef("string"))
.parameterType("query")
.required(true)
.build()))
.tags(new Tag("Bills & Payments Services", "All apis relating to B&P"));
// .additionalModels(typeResolver.resolve(AdditionalModel.class));
}
}
POM:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>