IntelliJ/Maven 回购问题

Pav*_*vel 3 java repository intellij-idea maven

我真的被这个问题惹恼了,这是我尝试修复它的第二天。我尝试了网络上所有可用的资源(在东部我能找到的)

我正在使用 Spring MVC 并尝试启动新的 Maven 项目。发生的事情是该项目是从模板构建的,这是我遇到的错误。

下载:

    https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/maven-metadata.xml
[WARNING] Could not transfer metadata org.apache.maven.plugins:maven-archetype-plugin/maven-metadata.xml from/to central (https://repo.maven.apache.org/maven2): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.224 s
[INFO] Finished at: 2018-08-28T11:52:04+01:00
[INFO] Final Memory: 7M/30M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-archetype-plugin:RELEASE or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-archetype-plugin:jar:RELEASE: Failed to resolve version for org.apache.maven.plugins:maven-archetype-plugin:jar:RELEASE: Could not find metadata org.apache.maven.plugins:maven-archetype-plugin/maven-metadata.xml in local (C:\Users\pgorski\.m2\repository) -> [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:
Run Code Online (Sandbox Code Playgroud)

当我在不使用原型的情况下构建新项目时,maven 根本无法工作 - 并出现以下错误:

1:当我检查 Maven 存储库时,我可以看到 repo.aven.apache.org/maven2 的错误:java.lang.RuntimeException: java.io.IOException: Transfer for nexus-maven-repository-index.properties failed。

2:当我检查Maven项目详细信息时,插件和依赖项带有红色下划线。

这是 mvn --debug 的输出:

[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
org.apache.maven.lifecycle.NoGoalSpecifiedException: No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy.
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:97)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    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 org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[ERROR]
[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/NoGoalSpecifiedException
Run Code Online (Sandbox Code Playgroud)

请帮忙

And*_*sel 5

根据原帖评论中提供的答案,我得出结论,贵公司使用代理拦截网络流量。本质上,它会动态地将公司特定的证书添加到您访问的所有 HTTPS 站点的证书路径的顶部。

要在 Java 应用程序中信任公司特定的证书,您必须将其添加到该应用程序使用的 Java 密钥库中。对于自带 JRE 的 Intellij IDEA,步骤如下:

  1. 在浏览器中转到https://www.google.com或任何其他 https 站点。单击地址栏左侧的锁定图标并按照 UI 获取有关认证路径的信息。在 Chrome 中,您可以在单击锁定图标后单击“证书”时打开的对话框的“证书路径”选项卡中查看此信息。

  2. 单击层次结构中最上面的证书(带有您公司名称的证书),然后单击“查看证书”。单击详细信息选项卡,然后单击复制到文件。按照小向导导出一个.cer Base64 编码的文件;让我们将其命名为Company。请注意,这些是 Chrome 特定的说明,但其他浏览器也有类似的步骤。

  3. 转到您的 Intellij IDEA 安装文件夹、子文件夹/jre64/bin(或 /jre32/bin)并将 Company.cer 复制到那里。

  4. 在复制证书的 bin 文件夹中打开 cmd 或 PowerShell(您可以在资源管理器中的空白区域上右键单击,Windows 上下文菜单将为您提供一个选项)。运行以下命令:

    keytool.exe -keystore ..\lib\security\cacerts -importcert -alias Company -file Company.cer

    当提示输入密码时,请使用changeit,这是默认的密钥库密码。当提示确认添加公司证书时,还要键入 yes。

  5. 重新启动 Intellij IDEA 并重试导致初始错误的操作。