Swagger+springboot Integration Integration (three-step view)

Source: Internet
Author: User

What is swagger?

Swagger is a background staff specialized testing a simple tool, especially suitable for the front-end separation of the project, before we have been using the postman, but this is a bit complicated, the path needs their own, and swagger is directly used, then we directly on the code said swagger, Literary talent is not good to forgive!

1. First two jar packages required

<dependency><groupid>io.springfox</groupid><artifactid>springfox-swagger2</ Artifactid><version>2.6.1</version></dependency><dependency><groupid> io.springfox</groupid><artifactid>springfox-swagger-ui</artifactid><version>2.6.1</ Version></dependency>

2. Configuring the Swagger Core class

@Configurationpublic class Swagger2 {@Beanpublic Docket Createrestapi () {return new docket (documentationtype.swagger_2 ). Apiinfo (Apiinfo ()). Select (). APIs (Requesthandlerselectors.basepackage (" Com.pcitc.scl.business.productoil.service.controller "))//own package name. Paths (Pathselectors.any ()). build ();} Private Apiinfo Apiinfo () {return new Apiinfobuilder (). Title ("Springboot build API documentation using swagger"). Description (" Simple and elegant restfun style, Http://blog.csdn.net/saytime "). Termsofserviceurl (" Http://blog.csdn.net/saytime "). Version (" 1.0 ") . build ();}}

3.springapppplication.java configuration in the Springboot core class

The main is to add annotations on the class @enableswagger2


Finally directly

Http://localhost:8080/swagger-ui.html


You can see your project, if the project name does not come up or the project does not start, please follow my other article


Swagger+springboot Integration Integration (three-step view)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.