java - Wiremock - 自动配置不加载存根
问题描述
我的wiremock 似乎不适用于自动配置。我在类路径中名为 stubs 的文件夹中有 json 文件,我在端口 8080 上运行了独立 jar。
@AutoConfigureWireMock(stubs="classpath:/stubs", port = 0)
public class TestResource {
@Autowired
private Service service;
@Test
public void contextLoads() throws Exception {
assertThat(this.service.go()).isEqualTo("Hello World!");
}
}
json 文件示例
{
"request" : {
"url" : "/api/users",
"method" : "GET",
"bodyPatterns" : [ {
"contains" : "some soap body"
}]
},
"response" : {
"status" : 200,
"body" : "Hello World",
"headers" : {
"X-Application-Context" : "application:-1",
"Content-Type" : "text/plain"
}
}
}
当我使用 GET -> localhost:8080/api/users/ 启动请求时,它与 json 文件不匹配。
提前致谢
解决方案
我只是在 localhost:8080/__admin/mappings/import http://wiremock.org/docs/stubbing/上使用 POST 请求添加了我所有的 json
推荐阅读
- php - 命名空间适用于一个类,但不适用于其他类
- stanford-nlp - 如何在斯坦福信息提取中的代码中设置标志
- javascript - nightwatch-黄瓜 ES6 --- nightwatch JS ES5
- javascript - 您能否检测到何时从浏览器 PDF 查看器打印或下载 PDF?
- python - __init__ 中的 Python 3 NameError,未定义“会话”
- r - 如何使用 R 绘制极坐标?
- c# - C# WPF MVVM XAML:使用 ContentPresenter 样式显示 ViewModel
- html - 为什么我的控制台中没有显示 send_email 功能?
- python - 我收到错误回溯(最近一次调用最后一次):for i in num_guesses: TypeError: 'int' object is not iterable
- c - C:父进程和多个子进程之间的读写