Swagger 2 integration with Spring boot application -


getting error while integrating swagger2 spring boot application. stuck implementation. problem implementation or configuration?

below configurations have done integrate swagger2.

swaggerconfig.java

import org.springframework.context.annotation.bean; import org.springframework.context.annotation.configuration;  import springfox.documentation.builders.pathselectors; import springfox.documentation.builders.requesthandlerselectors; import springfox.documentation.service.apiinfo; import springfox.documentation.spi.documentationtype; import springfox.documentation.spring.web.plugins.docket; import springfox.documentation.swagger2.annotations.enableswagger2;  @configuration @enableswagger2 public class swaggerconfig {     @bean     public docket api(){         return new docket(documentationtype.swagger_2)             .select()             .apis(requesthandlerselectors.any())             .paths(pathselectors.regex("/api/.*"))             .build()             .apiinfo(apiinfo());     }      @suppresswarnings("deprecation")     private apiinfo apiinfo() {         apiinfo apiinfo = new apiinfo(             "my project's rest api",             "this description of api.",             "api tos",             "me@wherever.com",             "api license",             "api license url", null         );         return apiinfo;     } } 

pom.xml

added required dependencies of swagger2

<dependency>     <groupid>io.springfox</groupid>     <artifactid>springfox-swagger2</artifactid>     <version>2.5.0</version> </dependency> <dependency>     <groupid>io.springfox</groupid>     <artifactid>springfox-swagger-ui</artifactid>     <version>2.5.0</version> </dependency> 

application.properties

server.port=10080 server.contextpath=/approot  ------------------hibernate datasource configuration------------------ spring.datasource.url=${.service.jdbc.url} spring.datasource.username=${service.jdbc.username} spring.datasource.password=${service.jdbc.password} spring.datasource.driver-class-name=${service.jdbc.driver}  spring.jpa.hibernate.ddl-auto: update spring.jpa.hibernate.naming_strategy: org.hibernate.cfg.improvednamingstrategy spring.jpa.show-sql: false  ------------------tomcat access logs------------------ server.tomcat.accesslogenabled=true server.tomcat.accesslogpattern=%t responsetime=%d remotehost=%h %l thread=%i %u method=%m uri=%u status=%s bytes=%b server.tomcat.basedir=/var/log/tomcat-access  error.whitelabel.enabled=false 

when trying access url http://localhost:10080/approot/swagger-ui.html, getting below error , nothing displayed on web page.

aug 08, 2016 11:48:05 org.apache.catalina.core.applicationdispatcher invoke severe: servlet.service() servlet dispatcherservlet threw exception javax.servlet.servletexception: circular view path [error]: dispatch current handler url [/approot/error] again. check viewresolver setup! (hint: may result of unspecified view, due default view name generation.)     @ org.springframework.web.servlet.view.internalresourceview.prepareforrendering(internalresourceview.java:205)     @ org.springframework.web.servlet.view.internalresourceview.rendermergedoutputmodel(internalresourceview.java:145)     @ org.springframework.web.servlet.view.abstractview.render(abstractview.java:303)     @ org.springframework.web.servlet.dispatcherservlet.render(dispatcherservlet.java:1228)     @ org.springframework.web.servlet.dispatcherservlet.processdispatchresult(dispatcherservlet.java:1011)     @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:955)     @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:877)     @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:966)     @ org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet.java:857)     @ javax.servlet.http.httpservlet.service(httpservlet.java:618)     @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:842)     @ javax.servlet.http.httpservlet.service(httpservlet.java:725)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:291)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206)     @ org.apache.catalina.core.applicationdispatcher.invoke(applicationdispatcher.java:721)     @ org.apache.catalina.core.applicationdispatcher.processrequest(applicationdispatcher.java:468)     @ org.apache.catalina.core.applicationdispatcher.doforward(applicationdispatcher.java:391)     @ org.apache.catalina.core.applicationdispatcher.forward(applicationdispatcher.java:318)     @ org.apache.catalina.core.standardhostvalve.custom(standardhostvalve.java:433)     @ org.apache.catalina.core.standardhostvalve.status(standardhostvalve.java:299)     @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:176)     @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:79)     @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:88)     @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:537)     @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1085)     @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:658)     @ org.apache.coyote.http11.http11nioprotocol$http11connectionhandler.process(http11nioprotocol.java:222)     @ org.apache.tomcat.util.net.nioendpoint$socketprocessor.dorun(nioendpoint.java:1556)     @ org.apache.tomcat.util.net.nioendpoint$socketprocessor.run(nioendpoint.java:1513)     @ java.util.concurrent.threadpoolexecutor.runworker(unknown source)     @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source)     @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61)     @ java.lang.thread.run(unknown source)  aug 08, 2016 11:48:05 org.apache.catalina.core.standardhostvalve custom severe: exception processing errorpage[errorcode=0, location=/error] javax.servlet.servletexception: circular view path [error]: dispatch current handler url [/approot/error] again. check viewresolver setup! (hint: may result of unspecified view, due default view name generation.)     @ org.springframework.web.servlet.view.internalresourceview.prepareforrendering(internalresourceview.java:205)     @ org.springframework.web.servlet.view.internalresourceview.rendermergedoutputmodel(internalresourceview.java:145)     @ org.springframework.web.servlet.view.abstractview.render(abstractview.java:303)     @ org.springframework.web.servlet.dispatcherservlet.render(dispatcherservlet.java:1228)     @ org.springframework.web.servlet.dispatcherservlet.processdispatchresult(dispatcherservlet.java:1011)     @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:955)     @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:877)     @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:966)     @ org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet.java:857)     @ javax.servlet.http.httpservlet.service(httpservlet.java:618)     @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:842)     @ javax.servlet.http.httpservlet.service(httpservlet.java:725)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:291)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206)     @ org.apache.catalina.core.applicationdispatcher.invoke(applicationdispatcher.java:721)     @ org.apache.catalina.core.applicationdispatcher.processrequest(applicationdispatcher.java:468)     @ org.apache.catalina.core.applicationdispatcher.doforward(applicationdispatcher.java:391)     @ org.apache.catalina.core.applicationdispatcher.forward(applicationdispatcher.java:318)     @ org.apache.catalina.core.standardhostvalve.custom(standardhostvalve.java:433)     @ org.apache.catalina.core.standardhostvalve.status(standardhostvalve.java:299)     @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:176)     @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:79)     @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:88)     @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:537)     @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1085)     @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:658)     @ org.apache.coyote.http11.http11nioprotocol$http11connectionhandler.process(http11nioprotocol.java:222)     @ org.apache.tomcat.util.net.nioendpoint$socketprocessor.dorun(nioendpoint.java:1556)     @ org.apache.tomcat.util.net.nioendpoint$socketprocessor.run(nioendpoint.java:1513)     @ java.util.concurrent.threadpoolexecutor.runworker(unknown source)     @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source)     @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61)     @ java.lang.thread.run(unknown source) 

i found solution problem. swagger ui adds own ui related modules jar file. there should not other @enablewebmvc in application if want see swagger ui. had annotation on 1 of exceptionhandler because of getting error when trying access swagger ui.

posted blog on integration of swagger spring boot application.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -