Вы должны добавить несколько библиотек, изменить отображение базового фильтра, я попытаюсь объяснить ниже:
- добавлены файлы jar в папку lib расширения вашего веб-сервиса:
classmate-1.3.1.jar
kxml2-2.1.8.jar
spring-plugin-core-1.2.0.RELEASE.jar
spring-plugin-metadata-1.2.0.RELEASE.jar
springfox-core-2.6.0.jar
springfox-schema-2.6.0.jar
springfox-spi-2.6.0.jar
springfox-spring-web-2.6.0.jar
springfox-swagger-common-2.6.0.jar
springfox-swagger-ui-2.6.0.jar
springfox-swagger2-2.6.0.jar
swagger-annotations-1.5.10.jar
swagger-models-1.5.10.jar
Переопределить этот класс WebConfig
@ EnableSwagger2
@Configuration
@ImportResource ({"WEB-INF / config / v2 / springmvc-v2-servlet.xml"})
открытый класс WebConfig расширяет WebMvcConfigurationSupport {
@Resource
private List<HttpMessageConverter<?>> messageConvertersV2;
@Resource
private List<HandlerExceptionResolver> exceptionResolversV2;
private ApplicationContext applicationContext;
@Override
@Bean
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
final CommerceHandlerMapping handlerMapping = new CommerceHandlerMapping("v2");
handlerMapping.setOrder(0);
handlerMapping.setDetectHandlerMethodsInAncestorContexts(true);
handlerMapping.setInterceptors(getInterceptors());
handlerMapping.setContentNegotiationManager(mvcContentNegotiationManager());
return handlerMapping;
}
@Override
protected void configureHandlerExceptionResolvers(final List<HandlerExceptionResolver> exceptionResolvers) {
final ExceptionHandlerExceptionResolver exceptionHandlerExceptionResolver = new ExceptionHandlerExceptionResolver();
exceptionHandlerExceptionResolver.setApplicationContext(applicationContext);
exceptionHandlerExceptionResolver.setContentNegotiationManager(mvcContentNegotiationManager());
exceptionHandlerExceptionResolver.setMessageConverters(getMessageConverters());
exceptionHandlerExceptionResolver.afterPropertiesSet();
exceptionResolvers.add(exceptionHandlerExceptionResolver);
exceptionResolvers.addAll(exceptionResolversV2);
exceptionResolvers.add(new ResponseStatusExceptionResolver());
exceptionResolvers.add(new DefaultHandlerExceptionResolver());
}
@Override
public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
super.setApplicationContext(applicationContext);
this.applicationContext = applicationContext;
}
@Override
public void configureContentNegotiation(final ContentNegotiationConfigurer configurer) {
configurer.favorPathExtension(false).favorParameter(true);
}
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry.addResourceHandler("**/swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
@Bean
public Docket api() {
final ApiInfo apiInfo = new ApiInfoBuilder().title("OCC API documentation")
.description("This document contains the generated API documentation for Omni Commerce Connect v2.")
.version("Version v2").build();
return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.any()).paths(PathSelectors.any())
.build().apiInfo(apiInfo);
}
}
Вы должны изменить отображение фильтра базового сайта в файле filter-config-v2-spring.xml.
<alias alias="baseSiteMatchingFilter" name="defaultBaseSiteMatchingFilter" />
<bean id="defaultBaseSiteMatchingFilter" class="com.yourbasesite.webservices.v2.filter.BaseSiteMatchingFilter">
<property name="regexp" value="(?!.*swagger.*)(?!.*api-docs.*)^/([^(/)]+)" />
<property name="baseSiteService" ref="baseSiteService" />
</bean>