Four step five minute spring4 rapid integration with swagger
If your company hasn't used swagger and hasn't even heard of swagger, quickly learn my blog. It's five minutes quick and fool like integration, but they will be shocked by such a simple application.
First of all, let's make a brief introduction to swagger: swagger is not only an artifact developed in the background, but also a channel for front-end and back-end communication. What can you do with swagger? First of all, you can basically say goodbye to unit testing in the future; Secondly, you don't have to write interface documents, and you don't need to maintain the documents after writing them. Swagger can completely simulate HTTP request, and difference between input and output is almost zero. Having said that, come directly to dry goods!
Integrated Trilogy:
Step 1: import two dependencies. If you are not a maven project, go find the jar package. Remember that only two are needed. I see that other tutorials have introduced seven or eight, which is a waste.
Step 2: add a class (just copy the following. Pay attention to modifying the package name and address)
Step 3: add the following configuration to the MVC configuration file. Your file may be called dispatcher xml! (just copy, no need to modify at all)
Step 4: add annotations on methods and parameters
On the method: @ apioperation (value = "tutorial", httpmethod = "post", notes = "tutorial") is placed in the input parameter: @ apiparam (required = true, name = "test", value = "tutorial input parameter")
I'm worried that some friends don't understand. Let's put a picture!
Step 5: start the service, and then enter in the browser:
http://ip:port/swagger -ui. html
The following screen represents success:
Note: if an interceptor is used in your project, please release the swagger resource (or you can directly copy the following configuration, all, do not doubt V2)
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.