question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting HTTP 404 error on /swagger-ui.html but other swagger endpoint works

See original GitHub issue

Getting HTTP 404 error on http://localhost:8080/myapp/swagger-ui.html, while integrating swagger-ui in RESTful API app (spring-boot app).

Other swagger endpoints are working as expected (/swagger-resources/configuration/ui, /swagger-resources/configuration/security, /v2/api-docs). I can see the JSON response.

  • Versions Info
    • spring-boot 1.3.5 (spring-boot-starter-tomcat).
    • Swagger 2.5.0 for both springfox-swagger2 & springfox-swagger-ui
  • This is a spring-boot app and serves RESTful api’s and does not have any static content. Hence no webapp, web, META-INF/resources etc folders in source code.
  • pom.xml
<dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.5.0</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.5.0</version>
        </dependency>
  • I am not using @EnableWebMvc anywhere in code
  • SwaggerConfiguration.java
@Configuration
@EnableSwagger2
@Profile("dev")
public class SwaggerConfiguration implements EnvironmentAware {
  @Bean
  public Docket swaggerSpringfoxDocket() {
    Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
            .genericModelSubstitutes(ResponseEntity.class).forCodeGeneration(true)
            .genericModelSubstitutes(ResponseEntity.class)
            .directModelSubstitute(LocalDate.class, String.class)
            .directModelSubstitute(LocalDateTime.class, Date.class)
            .directModelSubstitute(ZonedDateTime.class, Date.class).select()
            .paths(regex("/api/.*")).build();
    return docket;
  }
  private ApiInfo apiInfo() {
    return new ApiInfo(propertyResolver.getProperty("title"),
            propertyResolver.getProperty("description"),
            propertyResolver.getProperty("version"),
            propertyResolver.getProperty("termsOfServiceUrl"),
            new Contact(propertyResolver.getProperty("contact.name"),
                    propertyResolver.getProperty("contact.url"),
                    propertyResolver.getProperty("contact.email")),
            propertyResolver.getProperty("license"),
            propertyResolver.getProperty("licenseUrl"));
  }
  • Not sure if this will impact, but i do have below for configuring Metrics
@Configuration
public class WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer {
  @Autowired(required = false)
  private MetricRegistry metricRegistry;

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:31 (8 by maintainers)

github_iconTop GitHub Comments

20reactions
pavelkrylcommented, Jul 8, 2020

I also received 404 on getting HTML UI docs. I am having spring boot webflux project and the resolution was fairly simple: current 3.0.0-SNAPSHOT version changed the UI URL to /swagger-ui/ instead of the old /swagger-ui.html

Remove all you explicit tweaks and hacks and just depend on the new springfox-boot-starter as written here.

16reactions
jjathmancommented, Oct 14, 2016

I realize this is closed, but for people with similar problems the issue I had was we had a class extending the WebMvcConfigurationSupport and overriding methods, but we should have been using WebMvcConfigurerAdapter and overriding methods there. That fixed our issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger with Spring Boot 2.0 leads to 404 error page
By setting the logging level to "DEBUG", I was able to see endpoints for /v3/api-docs and they worked, but there was nothing about...
Read more >
Getting error 404 in deployed swagger project - Google Groups
Hello, I'm new to developing REST Web Services and Swagger. I'm using JAX-RS/Jersey and Eclipse and I already managed to configure and deploy...
Read more >
Help! My swagger controllers all return a 404 in .NET 6 - Medium
NET 6 last week and I was creating a new REST API using swagger. ... However when I tried to call an HTTP...
Read more >
Rest-doc Swagger UI returns 404 Resource not found on ...
Last week everything was fine but since my last builds the swagger UI of my app is returning 404 error “resource not found”....
Read more >
Installation - Swagger Documentation
docker run -p 80:8080 -e SWAGGER_JSON_URL=https://petstore3.swagger.io/api/v3/openapi.json swaggerapi/swagger-ui. The base URL of the web application can be ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found