Home > database >  No mapping for GET /swagger-ui.html
No mapping for GET /swagger-ui.html

Time:11-03

I am new in programming world. I tried use http://localhost:8080/swagger-ui.html but logs return 2022-11-03 04:27:28.476 WARN 13844 --- [nio-8080-exec-3] o.s.web.servlet.PageNotFound : No mapping for GET /swagger-ui.html

{

implementation 'io.springfox:springfox-swagger2:3.0.0'
implementation 'io.springfox:springfox-swagger-ui:3.0.0'

}

(sorry, for my english language)

package com.crud.tasks.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@EnableSwagger2
@Configuration
public class CoreConfiguration {

    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }
}

package com.crud.tasks;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;


@SpringBootApplication
@EnableWebMvc
public class TasksApplication {

   public static void main(String[] args) {
      SpringApplication.run(TasksApplication.class, args);
   }
}

CodePudding user response:

I had some problems implementing Swagger using 'spring fox swagger ui' , So Instead of it you can use 'Springdoc-open-api'. You may follow Swagger with openAPI .

CodePudding user response:

If you'd like to visualize API's using Swagger, I'd suggest to follow this simple tutorial.

No additional configurations required !

Simple steps

  1. Add below dependency
<groupId>org.springdoc</groupId>

<artifactId>springdoc-openapi-ui</artifactId>

<version>1.6.4</version>
  1. Access API after starting your Spring boot app at following path in browser

http://localhost:your_port/v3/api-docs/

  1. Use a custom path by modifying property , for e.g.

springdoc.api-docs.path=/api-docs

  1. Default integration is also available with below link

http://localhost:8080/swagger-ui.html

Follow this short and sweet tutorial https://www.baeldung.com/spring-rest-openapi-documentation

  • Related