How to simulate the use of interface tool moco in Java development
This article is about how to simulate the use of the interface tool moco in Java development. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it.
The use scenario of Analog Interface tool moco in Java Development
In development, you need to rely on some interfaces, such as requesting an interface that returns Json data, but the interface that returns Json data is either not built or the interaction is complex.
At this point, you can use moco to simulate the interface to return interface data for development and testing.
Realize
First open the Github of moco, and then download the jar package locally
Then create a new foo.json in the same directory as the jar package
[{"response": {"text": "badao"}}]
Then open the command line in this directory and enter:
Java-jar moco-runner-1.0.0-standalone.jar http-p 12306-c foo.json
Note that the version of the jar package here should be the same as that of your own jar package, which is 1.0.0
If the requested text is in Chinese, in order to prevent the browser from garbled, you need to modify the json file to
[{"response": {"text": "overbearing hooligan temperament", "headers": {"Content-Type": "text/html;charset=gbk"}]
Then run the above command line command
Then open a browser and enter:
Http://localhost:12306
What is Java? Java is an object-oriented programming language that can write desktop applications, Web applications, distributed systems, and embedded system applications.
The above is how to simulate the use of the interface tool moco in Java development. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.