英文:
How to start wiremock standalone with custom hostname?
问题
例如,我想要以主机名“my.abc.com”和端口9999启动独立的Wiremock。在哪里可以配置这个?或者主机名的正确命令行选项是什么?
提前非常感谢。
英文:
For example, I want to start wiremock standalone with hostname "my.abc.com" with port 9999. Where can I config that? Or what is the right command line options for hostname?
Thanks a lot in advance.
答案1
得分: 3
主机名由DNS或您的主机文件确定,而不是由WireMock本身确定。
如果您想在本地运行一切,但主机名不是localhost
,您可以编辑您的主机文件并添加一行,如下所示:
127.0.0.1 api.mydomain.com
然后,您可以访问本地运行的WireMock服务器,例如:http://api.mydomain.com:9999/
正如agoff所指出的,如果您想使用Java DSL与该实例交互,您需要进行配置:
WireMock.configureFor("api.mydomain.com", 9999);
主机文件可以在以下位置找到:
Windows - c:\Windows\System32\Drivers\etc\hosts
Mac - /private/etc/hosts
*nix - /etc/hosts
英文:
The hostname is determined by DNS or your host file, rather than WireMock itself.
If you want to run everything locally but with a hostname other than localhost
you can edit your hosts file and add a line like:
127.0.0.1 api.mydomain.com
Then you can hit a locally running WireMock server on e.g. http://api.mydomain.com:9999/
As agoff points out, if you want to use the Java DSL against the instance you need to configure it:
WireMock.configureFor("api.mydomain.com", 9999);
The host file can be found in the following places:
Windows - c:\Windows\System32\Drivers\etc\hosts
Mac - /private/etc/hosts
*nix - /etc/hosts
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论