Код: Выделить всё
@Configuration
public class DispatcherServletConfig {
@Bean
public DispatcherServlet dispatcherServlet() {
return new DispatcherServlet();
}
@Bean
public ServletRegistrationBean dispatcherServletRegistration() {
ServletRegistrationBean registration = new
ServletRegistrationBean(dispatcherServlet(), "/prefix1/*");
registration.addUrlMappings("/admin/*");
registration.addUrlMappings("/prefix2/*");
registration.setName(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
return registration;
}
}
private static final Set DEFAULT_PRODUCES_AND_CONSUMES =
new HashSet(Arrays.asList("application/json",
"application/xml"));
@Configuration
@EnableSwagger2
public class SwaggerConfig extends WebMvcConfigurationSupport {
private static final Set DEFAULT_PRODUCES_AND_CONSUMES =
new HashSet(Arrays.asList("application/json",
"application/xml"));
@Bean
public Docket api() {
ParameterBuilder aParameterBuilder = new ParameterBuilder();
aParameterBuilder.name("Authorization").modelRef(new ModelRef("string")).parameterType("header")
.description("Authorization Header").required(true).build();
List
aParameters = new ArrayList();
aParameters.add((Parameter) aParameterBuilder.build());
return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any()).build().apiInfo(apiInfo()).globalOperationParameters(aParameters).produces(DEFAULT_PRODUCES_AND_CONSUMES);
}
private ApiInfo apiInfo() {
Contact contact = new Contact("Pvt. Ltd.", "", "support@email.com");
return new ApiInfo("API", "Information related to api exposed by system.", "1.0",
"",
"", n e w A r r a y L i s t & l t ; & g t ; ( ) ) ; < b r / > } < b r / > } < b r / > < / c o d e > < b r / > Я д о бавил следующие зависимости в свой pom.xml:
org.apache.poi
poi-excelant
3.14
commons-fileupload
commons-fileupload
1.3
javax.mail
mail
1.4
com.ibm.icu
icu4j
3.4.4
org.springframework
spring-test
4.3.2.RELEASE
test
org.apache.httpcomponents
httpclient
4.4
javax.annotation
javax.annotation-api
1.2
junit
junit
4.12
test
com.itextpdf
itextpdf
5.0.6
com.opencsv
opencsv
3.8
commons-httpclient
commons-httpclient
3.1
org.apache.poi
poi-ooxml-schemas
3.11
org.apache.poi
poi-scratchpad
3.2-FINAL
org.apache.xmlbeans
xmlbeans
2.6.0
jstl
jstl
1.2
com.sun.jersey
jersey-bundle
1.19.1
org.mockito
mockito-all
1.10.19
test
org.scribe
scribe
1.3.7
com.squareup.retrofit2
retrofit
2.4.0
com.squareup.okhttp3
logging-interceptor
3.10.0
io.springfox
springfox-swagger2
2.8.0
io.springfox
springfox-swagger-ui
2.8.0
org.springframework
spring-jms
4.3.2.RELEASE
com.fasterxml.jackson.dataformat
jackson-dataformat-xml
2.9.6
com.google.code.gson
gson
2.8.0
com.squareup.retrofit2
retrofit
2.4.0
com.squareup.okhttp3
logging-interceptor
3.10.0
com.squareup.retrofit2
converter-jackson
2.4.0
Код: Выделить всё
io.github.robwin
swagger2markup-maven-plugin
0.9.3
${project.basedir}/apiDoc/json
swagger.json
${project.basedir}/apiDoc/asciidoc
asciidoc
process-classes
process-swagger
Я получаю ошибку 404 всякий раз, когда я вызываю свой {project_name}/prefix2/swagger- ui.html#

и когда угодно Я звоню {project_name}/swagger-ui.html# URL, я понял

Кроме того, файл swagger-ui.html не загружается в API.

Как я могу решить эту проблему?
Спасибо,
Подробнее здесь: https://stackoverflow.com/questions/534 ... springboot
Мобильная версия