error code 404 on /swagger-ui.html, non spring boot app
See original GitHub issueApplication is a non-boot app, I’ve tried almost all the possible solutions present on here but none of them seemed to work,
spring-boot-version: 2.1.6.RELEASE spring-webmvc : 5.1.8.RELEASE springfox-swagger2 : 2.9.2 springfox-swagger-ui : 2.9.2
the server starts but when I try /swagger-ui.html or api-docs it returns a 404. Other api(s) are working perfectly fine.
`@EnableWebMvc @EnableSwagger2 @Configuration public class SwaggerConfig extends WebMvcConfigurerAdapter {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any()).build();
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/swagger-ui.html");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
super.addResourceHandlers(registry);
}
} `
let me know if you need anything else. Please help
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Swagger with Spring Boot 2.0 leads to 404 error page
I was able to make it work with Spring boot version 2.0.4.RELEASE and this blog post: I added these dependencies:
Read more >Receiving 404 error on Swagger UI with Spring-Springboot
I had a similar problem where /swagger-ui.html (or the new endpoint version /swagger-ui/) returned 404, but the /v2/api-docs returned a valid json.
Read more >OpenApi 3 (Swagger UI), Spring Boot, Spring Security - Medium
antMatchers() rule to your SecurityConfig still has 404 error. I'm using: Spring Boot v2.4.1; Spring Security; OpenApi 3 with swagger-ui ...
Read more >Documenting a Spring REST API Using OpenAPI 3.0 - Baeldung
Learn how to generate OpenAPI 3.0 specifications for a Spring REST ... can generate a Spring Boot REST client using Swagger Code generator....
Read more >Springfox Reference Documentation - GitHub Pages
For non-boot applications springfox-swagger-ui is no longer ... In this example we override the 500 error code for all GET requests ….
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This should be fixed in 3.0.0. the new url in 3.0.0 is
/swagger-ui/index.html
or/swagger-ui/
rather than/swagger-ui.html
Hello, I am seeing the same error 404 on swagger end point. My application non-spring boot app (Using Spring 5.3.6 web application).
I am able to access /v2/api-docs but when I try /swagger-ui/ or /swagger-ui/index.html, I am seeing 404 not found error. Your suggestion on what I am doing wrong here, is much appreciated
POM <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>3.0.0</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>3.0.0</version> </dependency> Spring services XML
Swagger Config class @EnableSwagger2 public class SASwaggerConfig implements WebMvcConfigurer {
}