问题
My question about Spring boot jar.
When running jar on production machine as:
java -jar xyz.jar
It does not respond to my request. Because it is listening on ipv6.
But when I run application as
java -jar xyz.jar -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses
It responds my requests.
Is it the production machine's configuration which cause the application to listen over ipv6, or is there any other reasons?
Fortunately
-Djava.net.preferIPv4Stack=true
-Djava.net.preferIPv4Addresses
parameters solved my problem. But I am confused!!
Note: Tomcat is used as embedded server.
Spring boot version 1.5.4 RELEASE
回答1:
Here https://docs.oracle.com/javase/8/docs/technotes/guides/net/ipv6_guide/index.html I read that "The Java networking stack first checks whether IPv6 is supported on the underlying OS. If IPv6 is supported, it tries to use the IPv6 stack."
To check if your Linux machine supports IPv6, simply run "cat /proc/net/if_inet6" and if you see some output it means it's enabled.
来源:https://stackoverflow.com/questions/44718174/spring-boot-application-listens-over-ipv6-without-djava-net-preferipv4stack-tru