Maven 安装:安装文件目标在 Windows 上失败并出现套接字错误

问题描述 投票:0回答:2

我是第一次使用 Maven。我正在尝试将

spring-core.jar
添加到我的本地 Maven 存储库中。

Maven命令:

C:\Users\user\.m2\repository>mvn install:install-file -Dfile=C:\spring-core-4.2.0.RELEASE.jar -DgroupId=org.springframework -DartifactId=spring-core -Dversion=4.2.0.RELEASE -Dpackaging=jar

错误信息:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0.5/plexus-utils-3.0.5.pom
Dec 12, 2015 11:56:38 AM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo.maven.apache.org:443: Unrecognized Windows Sockets error: 10106: create
Dec 12, 2015 11:56:38 AM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo.maven.apache.org:443
Dec 12, 2015 11:56:38 AM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo.maven.apache.org:443: Unrecognized Windows Sockets error: 10106: create
Dec 12, 2015 11:56:38 AM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo.maven.apache.org:443
Dec 12, 2015 11:56:38 AM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo.maven.apache.org:443: Unrecognized Windows Sockets error: 10106: create
Dec 12, 2015 11:56:38 AM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo.maven.apache.org:443
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-digest/1.0/plexus-digest-1.0.pom
Dec 12, 2015 11:56:38 AM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo.maven.apache.org:443: Unrecognized Windows Sockets error: 10106: create
Dec 12, 2015 11:56:38 AM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo.maven.apache.org:443
Dec 12, 2015 11:56:38 AM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo.maven.apache.org:443: Unrecognized Windows Sockets error: 10106: create
Dec 12, 2015 11:56:38 AM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo.maven.apache.org:443
Dec 12, 2015 11:56:38 AM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo.maven.apache.org:443: Unrecognized Windows Sockets error: 10106: create
Dec 12, 2015 11:56:38 AM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo.maven.apache.org:443
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.414 s
[INFO] Finished at: 2015-12-12T11:56:38+05:30
[INFO] Final Memory: 9M/108M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install-file (default-cli) on project standalone-pom: Execution default-cli of goal org.apache.maven
    .plugins:maven-install-plugin:2.4:install-file failed: Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved: Failed to collect d
    ependencies at org.apache.maven.plugins:maven-install-plugin:jar:2.4 -> org.codehaus.plexus:plexus-utils:jar:3.0.5: Failed to read artifact descriptor for org.codehaus.plexus:plexus
    -utils:jar:3.0.5: Could not transfer artifact org.codehaus.plexus:plexus-utils:pom:3.0.5 from/to central (https://repo.maven.apache.org/maven2): Unrecognized Windows Sockets error:
    10106: create -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

请有人帮我解决这个错误,并让我知道如何将外部 jar 添加到我的 Maven 存储库。 谢谢!

java maven jar
2个回答
3
投票

此消息:

java.net.SocketException: Unrecognized Windows Sockets error: 10106: create

表示Maven无法打开10106端口。要么这个端口被阻塞,要么被使用。

扫描端口,即在 Windows 下:

Windows+R ---> cmd ---> 输入
netstat -b


2
投票

@letmedoit:您能解释一下为什么需要手动将工件添加到本地 Maven 存储库吗?

恕我直言,最好创建一个 pom.xml 文件并运行它。

将此文件 (pom.xml) 添加到计算机上的某个位置:


    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>yourGroupId</groupId>
      <artifactId>yourArtifactId</artifactId>
      <version>0-SNAPSHOT</version>
      <dependencies>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-core</artifactId>
          <version>4.2.0.RELEASE</version>
        </dependency>
      </dependencies>
    </project>
然后只需在放置前一个文件的目录中运行maven命令即可
mvn compile

它应该下载工件,如您所见:


    [INFO] Scanning for projects...
    [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building yourArtifactId 0-SNAPSHOT [INFO] ------------------------------------------------------------------------ Downloading: https://repo.maven.apache.org/maven2/org/springframework/spring-core/4.2.0.RELEASE/spring-core-4.2.0.RELEASE.pom Downloaded: https://repo.maven.apache.org/maven2/org/springframework/spring-core/4.2.0.RELEASE/spring-core-4.2.0.RELEASE.pom (3 KB at 5.4 KB/sec) Downloading: https://repo.maven.apache.org/maven2/org/springframework/spring-core/4.2.0.RELEASE/spring-core-4.2.0.RELEASE.jar Downloaded: https://repo.maven.apache.org/maven2/org/springframework/spring-core/4.2.0.RELEASE/spring-core-4.2.0.RELEASE.jar (1028 KB at 78.9 KB/sec) [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ yourArtifactId --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory /tmp/src/main/resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ yourArtifactId --- [INFO] No sources to compile [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 15.455 s [INFO] Finished at: 2015-12-12T11:02:37+01:00 [INFO] Final Memory: 10M/147M [INFO] ------------------------------------------------------------------------

© www.soinside.com 2019 - 2024. All rights reserved.