问题描述
我正在构建一个快速的网络爬虫,我需要多线程 DNS 解析,所以我选择了一个名为 dnsjava 的多线程 DNS 服务提供商.不幸的是,我不知道如何替换默认的 DNS 服务提供商.
我查看了 dnsjava 的 README 文件,但说明不是很通.>
替换标准的Java DNS功能:
从 Java 1.4 开始,服务提供程序可以在运行时加载.加载 dnsjava 服务提供者,按照上面的解释构建它并设置系统属性:
sun.net.spi.nameservice.provider.1=dns,dnsjava
这会指示 JVM 使用dnsjava 服务在以下位置提供 DNS最高优先级.
有几件事我不清楚:
- 在哪里放置 dnsjava.jar?
- 应该在哪里设置系统属性(是程序化的还是某种类型的文件更改)?
我在 Windows 7 机器上运行,我不确定我需要做什么来查找/修改系统属性...帮助!?
更新:
明白了:System.setProperty("sun.net.spi.nameservice.provider.1","dns,dnsjava");
胡乱猜测.
- 将 dnsjava.jar 文件放在应用程序的类路径中.
- 在应用程序中启动 main 方法之前设置系统属性.
I'm building a fast web crawler and I need to have multithreaded DNS resolution, so I picked up a multithreaded DNS service provider called dnsjava. Unfortunately, I can't figure out how to replace the default DNS Service Provider.
I went over the README file for dnsjava, but the instructions are not very through.
There are a couple of things that I'm unclear on:
- Where do I place the dnsjava.jar?
- Where is the system property supposed to be set (is it programmatic or some type of file change)?
I'm running on a Windows 7 machine and I'm not sure what I need to do to find/modify the system properties... help!?
Update:
Got it: System.setProperty("sun.net.spi.nameservice.provider.1","dns,dnsjava");
A wild guess.
- Put the dnsjava.jar file in the classpath of your application.
- Have the system property set before launching the main method in your application.
这篇关于如何更改java DNS服务提供者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!