> For the complete documentation index, see [llms.txt](https://spring-boot.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://spring-boot.shujuwajue.com/dan-yuan-ce-shi/wiremockwei-zao-fu-wu.md).

# WireMock伪造服务

可参考:[基于Wiremock创建Mock Service平台](https://www.cnblogs.com/ceshi2016/p/7883580.html)

1.下载jar包

2.运行WireMock server,模拟出来一个测试服务器

3.编写程序模拟测试结果,如下当访问`/book`时,则返回一个json对象.

```java
import static com.github.tomakehurst.wiremock.client.WireMock.*;

public class MockServer {

    public static void main(String[] args) {

        configureFor("127.0.0.1", 9999);

        stubFor(get(urlEqualTo("/book"))
                .willReturn(okJson("{'name':'tom'}")));


    }

}
```
