问题描述
我对Spring Boot jar的问题.在生产机上以以下方式运行jar时:
My question about Spring boot jar.When running jar on production machine as:
java -jar xyz.jar
java -jar xyz.jar
它没有回应我的要求.因为它正在监听ipv6.
It does not respond to my request. Because it is listening on ipv6.
但是当我以
身份运行应用程序时java -jar xyz.jar -Djava.net.preferIPv4Stack = true -Djava.net.preferIPv4Addresses
But when I run application as
java -jar xyz.jar -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses
它响应了我的请求.
是生产机器的配置导致应用程序通过ipv6侦听,还是有其他原因?
Is it the production machine's configuration which cause the application to listen over ipv6, or is there any other reasons?
幸运的是,
-Djava.net.preferIPv4Stack = true
-Djava.net.preferIPv4Addresses
参数解决了我的问题.但是我很困惑!!
注意:Tomcat被用作嵌入式服务器.
Spring引导版本1.5.4发布
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
推荐答案
此处 https://docs.oracle.com/javase/8/docs/technotes/guides/net/ipv6_guide/index.html 我读到"Java网络堆栈首先检查是否基础操作系统支持IPv6.如果支持IPv6,它将尝试使用IPv6堆栈."
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."
要检查您的Linux机器是否支持IPv6,只需运行"cat/proc/net/if_inet6",如果看到一些输出,则表示已启用.
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.
这篇关于Spring Boot应用程序在没有-Djava.net.preferIPv4Stack = true和-Djava.net.preferIPv4Addresses参数的情况下通过IPv6进行侦听的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!