Home > Back-end >  Integration of SSM Swagge appear Can 't read swagger JSON from http://localhost:8080/v2/api-doc
Integration of SSM Swagge appear Can 't read swagger JSON from http://localhost:8080/v2/api-doc

Time:09-29

Want to consult everybody bosses how to solve the problem of

This is applicationContext. The XML configuration file code
 

This is a swagger tools
 
Public class SwaggerConfig {
@ Bean
The public Docket API () {
Return new Docket (DocumentationType SWAGGER_2)
ApiInfo (apiInfo ()). The select ()
//scans the specified package swagger annotation
Apis (RequestHandlerSelectors. BasePackage (" com. Gx. Web "))
//apis (RequestHandlerSelectors basePackage (" com. Gx. Web "))
//scan all API annotations, in this way more flexible
Apis (RequestHandlerSelectors. WithMethodAnnotation (ApiOperation. Class))
Paths (PathSelectors. Any ())
.build();
}

/* *
* this is matching the API information
*
* @ return
*/
Private ApiInfo ApiInfo () {
Return new ApiInfoBuilder ()
. Title (" API documentation ")
. The description (" API test documents ")
TermsOfServiceUrl (" ")
License (" ")
Version (" 1.0.0 ")
.build();
}
}

This is the HTML the url in the address
 
Var url=window. The location. The search. The match (/url=(/^ & amp; +)/);
If (url & amp; & Url. The length & gt; 1) {
Url=decodeURIComponent (url [1]);
} else {
Url="/v2/API docs -";
}

This is the controller code
 
@ Controller
@ RequestMapping ("/user ")
@ Api (value="https://bbs.csdn.net/topics/user interface," description="user related Api")
Public class UserController {

Private Gson Gson=new GsonBuilder (.) setDateFormat (" MM - dd yyyy - HH: MM: ss "). The create ();
Private Object result;

The @autowired
Private IUserService userService;

@ RequestMapping ("/loginsPage ")
@ ApiOperation (value="https://bbs.csdn.net/topics/", notes="login" background, the response=ModelAndView. Class)
Public ModelAndView loginsPage () {
ModelAndView mv=new ModelAndView ("/login ");
Return the mv;
}
}

  • Related