简体   繁体   English

有什么方法可以在运行时刷新Java应用程序的DNS服务器详细信息吗?

[英]Is there any way to refresh DNS Server details of Java application at runtime?

We have an application which connects to the different applications using hostname. 我们有一个使用主机名连接到不同应用程序的应用程序。 If I change the DNS server of the system on which the application is running, the application starts to fail with "java.net.UnknownHostException". 如果更改运行该应用程序的系统的DNS服务器,该应用程序将因“ java.net.UnknownHostException”而开始失败。 But from the system I can send ping requests to different applications using FQDN. 但是我可以从系统中使用FQDN将ping请求发送到不同的应用程序。 To take effect of DNS server change, we have to restart the application. 为了使DNS服务器更改生效,我们必须重新启动应用程序。

Is there any way in Java where we can refresh the DNS server details at runtime ? Java中有什么方法可以在运行时刷新DNS服务器详细信息?

You can turn off dns caching for Java with 3 solutions: 您可以使用3种解决方案关闭Java的dns缓存:

Solution 1: 解决方案1:

Start your program with this flag: 使用以下标志启动程序:

-Dsun.net.inetaddr.ttl=0

Solution 2: 解决方案2:

At top of your java code use setProperty 在您的Java代码顶部,使用setProperty

java.security.Security.setProperty("networkaddress.cache.ttl" , "0")

Solution 3: 解决方案3:

In $JRE_HOME/lib/security/java.security set : $JRE_HOME/lib/security/java.security设置:

networkaddress.cache.ttl = 0
networkaddress.cache.negative.ttl = 0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有什么方法可以在Java应用程序的用户之间划分服务器资源? - Is there any way to divide server resources between users of Java application? 有没有办法在运行时动态编译 java 代码 - Is there any way to dynamically compile java code at runtime 有没有办法在小程序/任何 java 应用程序中使用 Java EE 中的 tomcat 服务器返回的信息? - Is there any way to use the information returned from tomcat server in Java EE in an applet / any java application? 应用程序服务器使用什么Java运行时环境? - What java runtime environment is used by an application server? 有没有办法让应用服务器上的慢查询超时 - Is there any way to timeout slow queries on application server 有什么方法可以通过Android应用程序自动检测Java服务器应用程序是否在线? - Is there any way to detect java server application is online automatically through android app? 有什么办法可以通过进程ID关闭Java应用程序? - Is there any way to close a Java application by process id? Java中的简单*权威DNS服务器* - Simple *Authoritative DNS Server* in Java 有没有办法在不使用任何解析器的情况下在 java 的特定位置添加另一个包含所有详细信息的标签 - Is there any way to add another tag with all the details at specific place in java without using any parser 有什么方法可以增加Netty中的DNS缓存TTL吗? - Is there any way to increase DNS cache TTL in netty?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM