更改JAVA DNS缓存设置 [英] Changing JAVA DNS Cache settings

查看:72
本文介绍了更改JAVA DNS缓存设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将java8用于我的Web应用程序.我想更改JAVA DNS缓存的设置.这是代码:

I am using java8 for my web application. I would like to change the settings of JAVA DNS Cache. This is the code:

java.security.Security.setProperty("networkaddress.cache.ttl", "60");
java.security.Security.setProperty("sun.net.inetaddr.negative.ttl", "10");

我想知道在DNS机会初始化之前,应该在哪里写代码(在哪个类文件中)以反映JVM中的更改.

I would like to know where exactly I should write the code (in which class file) to reflect the changes in JVM before DNS chance gets initialised.

我想使用Java实用程序类文件进行更改.请提出相同的建议.还建议如何在build.xml(ant)中配置相同的更改?

I would like to make the change using a java utility class file.Please suggest for the same. And also suggest how to configure the same change in build.xml(ant)?

我同意在他们建议更改安全文件的地方更新了答案.但是由于我在项目中的限制,我也想以其他方式了解配置.

I agree with answers updated where they have suggested to change security file.But i would like to know the configuration in other ways too due to limitations that i have in my project.

推荐答案

您最好的选择是直接在/lib/security

Your best bet is to set it directly in the java.security file located in /lib/security

注意:如果使用共享的JVM,则需要在启动命令 -Djava.security.properties =/DirectoryPath/filename 中进行设置,并设置security.overridePropertiesFile 设置为true.

Note: if you are using a shared JVM, you'll need to set this in your startup command -Djava.security.properties=/DirectoryPath/filename and set the value of security.overridePropertiesFile to true.

这篇关于更改JAVA DNS缓存设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆