0
votes

I have a spring boot project that is structured like below:

client
  build.gradle

interface
  build.gradle

service
  tests
  main
    java
    resources
 build.gradle

So there are three subprojects: interface,service and client.

The controllers are inside service>main>controller and the swagger is configured inside the build.gradle which is inside the service project. When i do localhost:8080/swagger-ui.html ,i get:

No mapping found for HTTP request with URI [/swagger-ui.html] in DispatcherServlet with name 'dispatcherServlet'.

I am able to get json when i hit this url: http://localhost:8080/v2/api-docs

2
have you included the swagger dist for the UI ? - Sampada
Yes i have the dist - Diva

2 Answers

8
votes

I got this working, I had a @EnableWebMVC on top of a class.Removing it fixed it. Thanks @Sampada for your help

0
votes

first, add below dependencies in spring boot pom file, then add @EnableSwagger annotation on the application class and then add webappconfig class

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.9.1</version>
</dependency>


<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.9.1</version>
</dependency>




@Configuration
@EnableWebMvc
public class ApplicationWebMvcConfig implements WebMvcConfigurer {
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer 
configurer) {
    configurer.enable();
    }

}