# 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'}")));


    }

}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://spring-boot.shujuwajue.com/dan-yuan-ce-shi/wiremockwei-zao-fu-wu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
