Java 如何在 IntelliJ IDEA 中添加 Nexus 存储库索引?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21628129/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 09:44:51  来源:igfitidea点击:

How to add Nexus repository index in IntelliJ IDEA?

javamavenintellij-idea

提问by fengyun

We managed our maven repository using Sonatype Nexus, and in the ~.m2\setting.xml, set

我们使用 Sonatype Nexus 管理我们的 Maven 存储库,并在 ~.m2\setting.xml 中设置

<mirrorOf>*</mirrorOf>

to our Nexus repository.

到我们的 Nexus 存储库。

In IntelliJ IDEA "Settings-->Maven-->Repositories-->Indexed Maven repositories", there are one local repository and one remote central repository "http://repo1.maven.org/maven2". However, there seems to be no way to index Nexus repository.

在IntelliJ IDEA“设置-->Maven-->Repositories-->Indexed Maven repositories”中,有一个本地仓库和一个远程中央仓库“ http://repo1.maven.org/maven2”。但是,似乎没有办法索引 Nexus 存储库。

Without the index, I can't use the "Maven Artifact Search" inside IntelliJ IDEA, instead I have to search it in Nexus website, and then copy the dependency to the pom.xml, which is not quite convenient.

没有索引,我无法使用IntelliJ IDEA中的“Maven Artifact Search”,而是必须在Nexus网站中搜索它,然后将依赖项复制到pom.xml中,这不是很方便。

Can anybody tell me how to add Nexus repository index in IntelliJ IDEA, so that I can search artifacts inside IDEA?

谁能告诉我如何在 IntelliJ IDEA 中添加 Nexus 存储库索引,以便我可以在 IDEA 中搜索工件?

below is my settings.xml:

下面是我的 settings.xml:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <name>My repository</name>
      <url>http://1.2.3.4:8081/nexus/content/groups/public</url>
    </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>nexus</id>
      <repositories>
        <repository>
          <id>central</id>
          <name>My repository</name>
          <url>http://repo1.maven.org/maven2</url>
          <layout>default</layout>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>warn</checksumPolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
            <checksumPolicy>fail</checksumPolicy>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://repo1.maven.org/maven2</url>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>warn</checksumPolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
            <checksumPolicy>fail</checksumPolicy>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>

  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>

回答by Steve K

AFA I know this isn't possible, using IntelliJ IDEA 13.1. The only Maven repositories that are supported are local or publicones, per the docs: https://www.jetbrains.com/idea/help/maven-repositories.html

AFA 我知道这是不可能的,使用 IntelliJ IDEA 13.1。根据文档,唯一受支持的 Maven 存储库是本地或公共存储库:https: //www.jetbrains.com/idea/help/maven-repositories.html

@CrazyCoder, correct me if I'm wrong...

@CrazyCoder,如果我错了,请纠正我...

Related: Adding maven repo in IntelliJ

相关:在 IntelliJ 中添加 maven repo