There are 4 properties that can be used to override the default behaviour.

networkaddress.cache.ttl (default: -1)
    Specified in java.security to indicate the caching policy for successful 
    name lookups from the name service. The value is specified as as integer 
    to indicate the number of seconds to cache the successful lookup.

    A value of -1 indicates "cache forever".

networkaddress.cache.negative.ttl (default: 10)
    Specified in java.security to indicate the caching policy for un-successful
    name lookups from the name service. The value is specified as as integer to 
    indicate the number of seconds to cache the failure for un-successful lookups.

    A value of 0 indicates "never cache". A value of -1 indicates "cache forever". 

sun.net.inetaddr.ttl
    This is a sun private system property which corresponds to networkaddress.cache.ttl. 
    It takes the same value and has the same meaning, but can be set as a command-line 
    option. However, the preferred way is to use the security property mentioned above. 

sun.net.inetaddr.negative.ttl
    This is a sun private system property which corresponds to networkaddress.cache.negative.ttl. 
    It takes the same value and has the same meaning, but can be set as a command-line option. 
    However, the preferred way is to use the security property mentioned above.

So you can disable caching by adding -Dsun.net.inetaddr.ttl=0 on the command line starting the JVM. But you can't set the value of networkaddress.cache.ttl on the command line. You can set the required value in the java.security file located in %JRE%\lib\security

networkaddress.cache.ttl=60
networkaddress.cache.negative.ttl=10

or set the value in your code with

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

相关文章:

  • 2022-12-23
  • 2021-09-02
  • 2021-08-01
  • 2021-09-15
  • 2021-09-15
猜你喜欢
  • 2021-11-27
  • 2021-06-14
  • 2022-12-23
  • 2021-09-15
相关资源
相似解决方案