当我在 Mac - OS X - 10.11.2 (El Capitan) 上的 IntelliJ 上运行 JUnit 测试时,遇到以下错误。
Can't assign requested address - 127.0.0.2:27425
我正在运行的 JUnit 测试已经设置完毕,并且在 Ubuntu/RHEL/Windows 上运行时运行良好。
我猜问题是 Mac 无法将 127.0.0.* 识别为 localhost。
我尝试了以下方法,但没有成功。
运行此命令以别名 localhost 表示 2 <= i <= 255
sudo ifconfig lo0 -alias 127.0.0.$i up
将以下行添加到/etc/hosts
127.0.0.2 localhost 127.0.0.3 localhost ... ... 127.0.0.255 localhost
非常感谢任何修复/解决此问题的提示/建议。
最佳答案
super 用户交换的可能解决方案:
Here is the short answer: sudo ifconfig lo0 alias 127.0.0.* up
Each alias must be added individually (sudo ifconfig lo0 alias 127.0.0.2 up, sudo ifconfig lo0 alias 127.0.0.3 up). It can be done manually for testing, or a subset or the complete list of the other 250 available numbers in that subnet can be made into StartupItems script that will do it automagically at boot time.
The long answer: According to RFC3330, 127.0.0.0/8 - This block is assigned for use as the Internet host loopback address. A datagram sent by a higher level protocol to an address anywhere within this block should loop back inside the host. This is ordinarily implemented using only 127.0.0.1/32 for loopback, but no addresses within this block should ever appear on any network anywhere.
关于macos - OS X 上 IntelliJ 上的 JUnit - 无法分配请求的地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34421505/