macos - OS X 上 IntelliJ 上的 JUnit - 无法分配请求的地址

标签 macos intellij-idea junit

当我在 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。

我尝试了以下方法,但没有成功。

  1. 运行此命令以别名 localhost 表示 2 <= i <= 255

    sudo ifconfig lo0 -alias 127.0.0.$i up
    
  2. 将以下行添加到/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.

这是Original post

关于macos - OS X 上 IntelliJ 上的 JUnit - 无法分配请求的地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34421505/

相关文章:

excel - 更改 Excel for Mac 的 VBE 的默认字体大小

windows - Macintosh 是否有像 Windows 一样基于消息的范例?

intellij-idea - 重构重命名在 Intellij IDEA 中损坏

java - 用于比较两个空对象的 junit 测试用例

android - 是否可以测试 Activity 类中的方法?

macOS 64 位系统调用表

macos - Docker组成的容器在osx领域中彼此不交谈

debugging - IntelliJ : Is it possible to start debugger with breakpoints muted?

java - 在 IntelliJ 中,是否有可以跳转到上次查看的选项卡的操作?

java - Struts2 Junit case 在 mvn 测试期间抛出错误