github地址: https://github.com/jamesdbloom/mockserver
1. org.apache.maven.plugin-tools:maven-plugin-annotations:jar:3.5.2 安装
https://mvnrepository.com/artifact/org.apache.maven.plugin-tools/maven-plugin-annotations/3.5.2
2. mockserver使用
java -Dmockserver.initializationJsonPath="test02.json" -jar mockserver-netty-5.5.1-jar-with-dependencies.jar -serverPort 1080 -logLevel INFO
test2.json内容:
[{
"httpRequest": {
"path": "/simpleFirst"},
"httpResponse": {
"body": "some first response"}},{
"httpRequest": {
"path": "/simpleSecond"},
"httpResponse": {
"body": "some second response"
}}]
3.查看进程占用的端口号:
a)netstat -ano|findstr 1099
TCP 0.0.0.0:1099 0.0.0.0:0 LISTENING 18820
TCP [::]:1099 [::]:0 LISTENING 18820
b)关闭占用端口的进程:
taskkill /f /pid 18820
错误: 无法终止 PID 为 18820 的进程。
原因: 只能强行终止这个进程(带 /F 选项)。