Intellij无法连接到本地m2存储库

时间:2017-08-29 01:10:28

标签: java maven intellij-idea pom.xml

摘要

我已经看到了一些问题[1] [2] [3],但这些问题都没有取得任何成功。

所以,以下是我看到的问题:

1)pom表示它无法连接到本地.m2存储库。

2)Intellij中的Maven设置显示与本地.m2存储库的连接被拒绝的错误。

enter image description here

Connection to local repository has been refused

到目前为止我尝试过:

链接问题中的所有内容。包括:

手动

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"

非常感谢任何帮助。

Idea.log

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面板调用,您的构建是否有效?

构建失败,说明找不到很多符号。

2 个答案:

答案 0 :(得分:6)

终于弄明白了这个问题。我的/etc/hosts文件中存在无效字符,阻止了与localhost的任何连接。当我输入以下命令时发现了这个:

$ file -b /etc/hosts
UTF-8 Unicode text

我在etc host中手动输入了正确的值,现在一切都按预期工作了。

答案 1 :(得分:4)

我有两点建议:

  1. 如果有代理,请在setting.xml中添加其配置参数 您必须指定:

    <proxy> <active></active> <protocol></protocol> <host></host> <port></port> <username></username> <password></password> </proxy>

  2. 在主机文件中复制/粘贴 127.0.0.1 localhost