@Bean Public Docket Customimplementation () { return new docket (documentationtype.swagger_2) . Select () . APIs (requesthandlerselectors.basepackage ("Com.xx.controller")) . Build () . Directmodelsubstitute (Org.joda.time.LocalDate.class, Java.sql.Date.class) . Directmodelsubstitute ( Org.joda.time.DateTime.class, Java.util.Date.class) . Apiinfo (Apiinfo ()); }
As shown, using basepackage scan Com.xx.controller, after starting the project to access http://127.0.0.1:8088/swagger-ui.html, the swagger UI can load into the browser normally, The problem is that only header headers, no interface documents.
Then replace the following:
@Bean Public Docket API () { return new docket (documentationtype.swagger_2) . Apiinfo (Apiinfo ()) . Select () . APIs (requesthandlerselectors.withmethodannotation (apioperation.class)) . Build (); }
Change the condition of the Basepackage scan to Requesthandlerselectors.withmethodannotation (Apioperation.class), Scan the Apioperation annotated modified controller to restart the project, the interface document is displayed properly.
"Original" Spring Boot configuration Swagger2 No document solution