Dariusz Mydlarz Dariusz Mydlarz - 5 days ago 6
Java Question

How to enable Swagger UI? Tomcat, SpringMVC, REST

My configuration is as follow:

pom.xml

<dependencies>
<!-- Swagger -->
<dependency>
<groupId>com.mangofactory</groupId>
<artifactId>swagger-springmvc</artifactId>
<version>0.9.1</version>
</dependency>

<!-- Swagger WebJar -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
<version>2.0.24</version>
</dependency>
</dependencies>


root-context.xml

<mvc:annotation-driven/>
<beans:bean class="com.mangofactory.swagger.configuration.SpringSwaggerConfig" />


I deploy my application into Tomcat 8.0. I am able to see Swagger JSON data at URI:

http://localhost:8080/myapp/api-docs


But I can't run Swagger UI. What more should I do to run Swagger UI in my project?

Answer

I solved my problem by adding swagger-ui resources to

src\main\webapp\docs

I also added

<mvc:default-servlet-handler/>

To pom.xml

Now I can access swagger UI under:

http://localhost:8080/myapp/docs/
Comments