如何将IntelliJ IDEA随机开放端口绑定到localhost?

时间:2017-04-11 20:41:32

标签: java intellij-idea

当我在macOS上运行IntelliJ IDEA 2019.1.2(终极版或社区版)时,我发现在所有网络接口(eth0,lo,...)上都打开了3个随机端口。一个随机端口由构思过程打开,另外两个端口由IntelliJ IDEA启动的不同java进程打开。

我删除了我明确安装的唯一插件SonarLint。

在端口63342上运行的调试器绑定到localhost,可以在“首选项”菜单中进行配置。

以下是lsof -i | grep LISTEN输出的相关部分:

    idea   3328    orto  187u  IPv4 0x3c332685aa6872fd   0t0  TCP localhost:6942 (LISTEN)
    idea   3328    orto  686u  IPv4 0x3c332685aa623815   0t0  TCP localhost:63342 (LISTEN)
    idea   3328    orto  752u  IPv4 0x3c332685aa676de5   0t0  TCP *:53212 (LISTEN)
    java   3341    orto   33u  IPv6 0x3c332685aa5f899d   0t0  TCP *:61070 (LISTEN)
    java   3341    orto   77u  IPv6 0x3c332685b9885edd   0t0  TCP *:53210 (LISTEN)

如上所述,这是ps -ef | grep 3341的相关部分(它是RemoteMavenServer):

/Applications/IntelliJ IDEA.app/Contents/jdk/Contents/Home/jre/bin/java -d64 -Djava.awt.headless=true -Didea.version==2017.1.1 -Xmx768m -Didea.maven.embedder.version=3.3.9 -Dfile.encoding=UTF-8 -classpath /Applications/IntelliJ IDEA.app/Contents/lib/resources_en.jar:/Applications/IntelliJ IDEA.app/Contents/lib/log4j.jar:/Applications/IntelliJ IDEA.app/Contents/lib/snappy-in-java-0.5.1.jar:/Applications/IntelliJ IDEA.app/Contents/lib/jna.jar:/Applications/IntelliJ IDEA.app/Contents/lib/jna-platform.jar:/Applications/IntelliJ IDEA.app/Contents/lib/annotations.jar:/Applications/IntelliJ IDEA.app/Contents/lib/oromatcher.jar:/Applications/IntelliJ IDEA.app/Contents/lib/trove4j.jar:/Applications/IntelliJ IDEA.app/Contents/lib/util.jar:/Applications/IntelliJ IDEA.app/Contents/lib/jdom.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/lucene-core-2.4.1.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven-server-api.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3-server-common.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3-server-lib/archetype-catalog-2.2.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3-server-lib/archetype-common-2.2.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3-server-lib/maven-dependency-tree-1.2.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3-server-lib/nexus-indexer-3.0.4.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3-server-lib/nexus-indexer-artifact-1.0.1.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3-server-impl.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/aether-api-1.0.2.v20150114.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/aether-connector-basic-1.0.2.v20150114.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/aether-impl-1.0.2.v20150114.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/aether-spi-1.0.2.v20150114.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/aether-transport-wagon-1.0.2.v20150114.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/aether-util-1.0.2.v20150114.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/aopalliance-1.0.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/cdi-api-1.0.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/commons-cli-1.2.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/commons-io-2.2.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/commons-lang-2.6.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/commons-lang3-3.4.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/guava-18.0.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/guice-4.0-no_aop.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/javax.inject-1.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/jsoup-1.7.2.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/jsr250-api-1.0.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/maven-aether-provider-3.3.9.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/maven-artifact-3.3.9.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/maven-builder-support-3.3.9.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/maven-compat-3.3.9.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/maven-core-3.3.9.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/maven-embedder-3.3.9.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/maven-model-3.3.9.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/maven-model-builder-3.3.9.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/maven-plugin-api-3.3.9.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/maven-repository-metadata-3.3.9.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/maven-settings-3.3.9.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/maven-settings-builder-3.3.9.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/org.eclipse.sisu.inject-0.3.2.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/org.eclipse.sisu.plexus-0.3.2.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/plexus-cipher-1.7.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/plexus-component-annotations-1.6.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/plexus-interpolation-1.21.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/plexus-sec-dispatcher-1.3.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/plexus-utils-3.0.22.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/slf4j-api-1.7.5.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/slf4j-simple-1.7.5.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/wagon-file-2.10.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/wagon-http-2.10-shaded.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/wagon-http-shared-2.10.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/lib/wagon-provider-api-2.10.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/boot/plexus-classworlds-2.5.2.jar org.jetbrains.idea.maven.server.RemoteMavenServer

如何将这三个随机开放端口绑定到localhost?

P.S。:我正在使用macos版本。

P.S.2:此处创建了一个问题:https://youtrack.jetbrains.com/issue/IDEA-175889

1 个答案:

答案 0 :(得分:4)

默认情况下,IntelliJ IDEA不会绑定通配符接口上的任何端口,但UDP并发许可检查除外(仅适用于Ultimate)。用于内部需求的所有端口(Netty库初始化,独占文件夹锁定,内置Web服务器,调试器,编译器/ maven / gradle /运行进程IPC)在dstlocalhost)上打开接口:

ports