Intellij 无法连接到本地 m2 存储库
Posted
技术标签:
【中文标题】Intellij 无法连接到本地 m2 存储库【英文标题】:Intellij can't connect to local m2 repository 【发布时间】:2018-02-06 07:56:47 【问题描述】:总结
我看到过一些问题[1][2][3] 与此有些相似,但没有一个答案能产生任何形式的成功。
所以,这是我看到的问题:
1) pom 提示无法连接到本地 .m2 存储库。
2) Intellij 中的 Maven 设置显示与本地 .m2 存储库的连接被拒绝的错误。
到目前为止我所做的尝试:
链接问题中的几乎所有内容。其中:
1) Delete the entire .m2/repository 文件夹手动,然后再次更新您的 Maven 项目。
2)Invalidate your Idea cache and restart Idea.
3)increasing Maven's allocated memory
4) Setting localhost to only 127.0.0.1
5)Adding -Djava.net.preferIPv4Stack=true flag
6) Starting Intellij with Java 1.7 instead of 1.8
7) 卸载并重新安装 Maven、Java 和 Intellij
其他信息:
$ java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
$ mvn -version
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T12:39:06-07:00)
Maven home: /usr/local/apache-maven-3.5.0
Java version: 1.8.0_144, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.6", arch: "x86_64", family: "mac"
非常感谢任何帮助。
创意日志
2017-08-29 13:16:51,471 [12172337] WARN - #org.jetbrains.idea.maven - Failed to update Maven indices for: [local] /Users/donato/.m2/repository
org.jetbrains.idea.maven.server.MavenServerIndexerException: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused (Connection refused)
at org.jetbrains.idea.maven.server.Maven3ServerIndexerImpl.updateIndex(Maven3ServerIndexerImpl.java:221)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:276)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:253)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:162)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179)
at com.sun.proxy.$Proxy137.updateIndex(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.execution.rmi.RemoteUtil.invokeRemote(RemoteUtil.java:175)
at com.intellij.execution.rmi.RemoteUtil.access$300(RemoteUtil.java:36)
at com.intellij.execution.rmi.RemoteUtil$2$1$1.compute(RemoteUtil.java:156)
at com.intellij.execution.rmi.RemoteUtil.executeWithClassLoader(RemoteUtil.java:232)
at com.intellij.execution.rmi.RemoteUtil$2$1.invoke(RemoteUtil.java:153)
at com.sun.proxy.$Proxy137.updateIndex(Unknown Source)
at org.jetbrains.idea.maven.server.MavenIndexerWrapper$3.execute(MavenIndexerWrapper.java:120)
at org.jetbrains.idea.maven.server.RemoteObjectWrapper.perform(RemoteObjectWrapper.java:118)
at org.jetbrains.idea.maven.server.MavenIndexerWrapper.updateIndex(MavenIndexerWrapper.java:115)
at org.jetbrains.idea.maven.indices.MavenIndex.updateContext(MavenIndex.java:371)
at org.jetbrains.idea.maven.indices.MavenIndex.updateOrRepair(MavenIndex.java:329)
at org.jetbrains.idea.maven.indices.MavenIndices.updateOrRepair(MavenIndices.java:128)
at org.jetbrains.idea.maven.indices.MavenIndicesManager.doUpdateIndices(MavenIndicesManager.java:276)
at org.jetbrains.idea.maven.indices.MavenIndicesManager.access$200(MavenIndicesManager.java:52)
at org.jetbrains.idea.maven.indices.MavenIndicesManager$3.run(MavenIndicesManager.java:243)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:718)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:170)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:548)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:493)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:94)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:157)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:165)
at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:343)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused (Connection refused)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:130)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179)
at com.sun.proxy.$Proxy29.setIndeterminate(Unknown Source)
at org.jetbrains.idea.maven.server.Maven3ServerIndexerImpl.updateIndex(Maven3ServerIndexerImpl.java:152)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.<init>(Socket.java:434)
at java.net.Socket.<init>(Socket.java:211)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
... 24 more
2017-08-29 13:17:07,836 [12188702] WARN - ution.rmi.RemoteProcessSupport - java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
2017-08-29 13:17:07,841 [12188707] WARN - ution.rmi.RemoteProcessSupport - java.net.ConnectException: Connection refused (Connection refused)
2017-08-29 13:17:07,841 [12188707] WARN - ution.rmi.RemoteProcessSupport - at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
2017-08-29 13:17:07,841 [12188707] WARN - ution.rmi.RemoteProcessSupport - at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
2017-08-29 13:17:07,841 [12188707] WARN - ution.rmi.RemoteProcessSupport - at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
2017-08-29 13:17:07,841 [12188707] WARN - ution.rmi.RemoteProcessSupport - at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:130)
2017-08-29 13:17:07,841 [12188707] WARN - ution.rmi.RemoteProcessSupport - at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227)
2017-08-29 13:17:07,841 [12188707] WARN - ution.rmi.RemoteProcessSupport - at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179)
2017-08-29 13:17:07,841 [12188707] WARN - ution.rmi.RemoteProcessSupport - at com.sun.proxy.$Proxy1.ping(Unknown Source)
2017-08-29 13:17:07,841 [12188707] WARN - ution.rmi.RemoteProcessSupport - at com.intellij.execution.rmi.RemoteServer.start(RemoteServer.java:83)
2017-08-29 13:17:07,841 [12188707] WARN - ution.rmi.RemoteProcessSupport - at org.jetbrains.idea.maven.server.RemoteMavenServer.main(RemoteMavenServer.java:22)
2017-08-29 13:17:07,841 [12188707] WARN - ution.rmi.RemoteProcessSupport - Caused by: java.net.ConnectException: Connection refused (Connection refused)
2017-08-29 13:17:07,841 [12188707] WARN - ution.rmi.RemoteProcessSupport - at java.net.PlainSocketImpl.socketConnect(Native Method)
2017-08-29 13:17:07,841 [12188707] WARN - ution.rmi.RemoteProcessSupport - at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
2017-08-29 13:17:07,842 [12188708] WARN - ution.rmi.RemoteProcessSupport - at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
2017-08-29 13:17:07,842 [12188708] WARN - ution.rmi.RemoteProcessSupport - at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
2017-08-29 13:17:07,842 [12188708] WARN - ution.rmi.RemoteProcessSupport - at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
2017-08-29 13:17:07,842 [12188708] WARN - ution.rmi.RemoteProcessSupport - at java.net.Socket.connect(Socket.java:589)
2017-08-29 13:17:07,842 [12188708] WARN - ution.rmi.RemoteProcessSupport - at java.net.Socket.connect(Socket.java:538)
2017-08-29 13:17:07,842 [12188708] WARN - ution.rmi.RemoteProcessSupport - at java.net.Socket.<init>(Socket.java:434)
2017-08-29 13:17:07,842 [12188708] WARN - ution.rmi.RemoteProcessSupport - at java.net.Socket.<init>(Socket.java:211)
2017-08-29 13:17:07,842 [12188708] WARN - ution.rmi.RemoteProcessSupport - at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
2017-08-29 13:17:07,842 [12188708] WARN - ution.rmi.RemoteProcessSupport - at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148)
2017-08-29 13:17:07,842 [12188708] WARN - ution.rmi.RemoteProcessSupport - at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
2017-08-29 13:17:07,842 [12188708] WARN - ution.rmi.RemoteProcessSupport - ... 8 more
2017-08-29 13:17:21,180 [12202046] INFO - .script.IdeScriptEngineManager - javax.script.ScriptEngineManager initialized in 34 ms
2017-08-29 13:17:23,080 [12203946] INFO - ij.compiler.impl.CompileDriver - COMPILATION STARTED (BUILD PROCESS)
2017-08-29 13:17:23,756 [12204622] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stdout]: Build process started. Classpath: /Applications/IntelliJ IDEA CE.app/Contents/lib/jps-launcher.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/tools.jar:/Applications/IntelliJ IDEA CE.app/Contents/lib/optimizedFileManager.jar
2017-08-29 13:17:23,859 [12204725] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
2017-08-29 13:17:23,860 [12204726] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Defaulting to no-operation (NOP) logger implementation
2017-08-29 13:17:23,860 [12204726] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2017-08-29 13:17:27,244 [12208110] INFO - pl.ProjectRootManagerComponent - project roots have changed
2017-08-29 13:17:27,299 [12208165] INFO - pl.ProjectRootManagerComponent - project roots have changed
2017-08-29 13:17:27,305 [12208171] INFO - .diagnostic.PerformanceWatcher - Pushing properties took 0ms; general responsiveness: ok; EDT responsiveness: ok
2017-08-29 13:17:27,324 [12208190] INFO - indexing.UnindexedFilesUpdater - Unindexed files update canceled
2017-08-29 13:17:27,325 [12208191] INFO - pl.ProjectRootManagerComponent - project roots have changed
2017-08-29 13:17:27,333 [12208199] INFO - .diagnostic.PerformanceWatcher - Pushing properties took 2ms; general responsiveness: ok; EDT responsiveness: ok
2017-08-29 13:17:27,336 [12208202] INFO - lij.compiler.impl.CompilerUtil - COMPILATION FINISHED (BUILD PROCESS); Errors: 100; warnings: 3 took 4150 ms: 0 min 4sec
2017-08-29 13:17:27,365 [12208231] INFO - s.CompilerReferenceServiceImpl - backward reference index reader is opened
2017-08-29 13:17:27,369 [12208235] INFO - .diagnostic.PerformanceWatcher - Indexable file iteration took 36ms; general responsiveness: ok; EDT responsiveness: ok
2017-08-29 13:17:27,635 [12208501] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stdout]: Build process started. Classpath: /Applications/IntelliJ IDEA CE.app/Contents/lib/jps-launcher.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/tools.jar:/Applications/IntelliJ IDEA CE.app/Contents/lib/optimizedFileManager.jar
2017-08-29 13:17:27,704 [12208570] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
2017-08-29 13:17:27,704 [12208570] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Defaulting to no-operation (NOP) logger implementation
2017-08-29 13:17:27,704 [12208570] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
更新
您使用的是哪个settings.xml
?
/Users/donato/.m2/settings.xml
您在 IntelliJ 中打开的任何 Maven 项目是否会发生这种情况,或者只是这个项目?
所有 maven 项目都会出现这种情况
此外,除了 Intellij 显示索引失败之外,如果从 Maven 面板调用,您的构建是否有效?
构建失败,提示找不到很多符号。
【问题讨论】:
如果没有idea.log 中的错误,则无法判断您的具体情况是什么问题。另请参阅***.com/a/42427510/104891。 您在 IntelliJ 中打开的任何 Maven 项目是否会发生这种情况,或者只是这个项目?此外,除了 Intellij 显示索引失败之外,如果从 Maven 面板调用,您的构建是否有效? 您使用的是哪个settings.xml
?在这里检查:文件 > 设置 > 构建,.. > 构建工具 > Maven > 用户设置文件
关于settings.xml
我的意思是IDEA使用的这个文件是否包含存储库的正确路径?如果文件不存在,则默认位置为~/.m2
您是否有防火墙阻止 IntelliJ 接受某些传入的网络连接?看到这个帖子why-does-intellij-want-to-accept-incoming-network-connections。纯属猜测。
【参考方案1】:
终于解决了问题。我的/etc/hosts
文件中有一个无效字符,它阻止了与本地主机的任何连接。这是在我输入以下命令时发现的:
$ file -b /etc/hosts
UTF-8 Unicode text
我在 etc 主机中手动输入了正确的值,现在一切正常。
【讨论】:
【参考方案2】:我有两个建议:
如果有代理,在setting.xml中添加其配置参数 您必须指定:
<proxy>
<active></active>
<protocol></protocol>
<host></host>
<port></port>
<username></username>
<password></password>
</proxy>
复制/粘贴 127.0.0.1 localhost 到您的主机文件中
【讨论】:
以上是关于Intellij 无法连接到本地 m2 存储库的主要内容,如果未能解决你的问题,请参考以下文章
如何强制 IntelliJ 中的 Maven 从本地 .m2 存储库中提取特定依赖项
无法从Intellij连接到在docker容器中运行的mySql - “指定的数据库用户/密码组合被拒绝”