maven - 在 Idea Intellij 中使用 Nexus 存储库而不是公共(public) Maven

标签 maven nexus

如何强制 Idea Intellij 从 Nexus 存储库而不是 Maven 公共(public)存储库下载?
我可以在 Idea 属性中的哪里配置它?pom.xml 中未定义文件,我不想这样做。

最佳答案

不确定它是否也适用于 Idea Intellij(我正在使用 spring source studio - eclipse clon),但应该因为 maven 配置位于主目录中 .M2 目录的 settings.xml 中。只需使用这样的东西(我的服务器在 nexus-server:8081 上运行):

<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">
  <servers>
    <server> 
      <id>releases</id>
      <username>user-name</username>
      <password>your-password</password>
    </server>
    <server> 
      <id>snapshots</id>
      <username>user-name</username>
      <password>your-password</password>
    </server>
  </servers>
    <mirrors>
        <mirror>
            <!--This sends everything else to /public -->
            <id>nexus</id>
            <mirrorOf>*</mirrorOf>
            <url>http://nexus-server:8081/nexus/content/groups/public</url>
        </mirror>
    </mirrors>
    <profiles>
        <profile>
            <id>nexus</id>
            <!--Disable snapshots for the built in central repo to direct -->
            <!--all requests to nexus via the mirror -->
            <repositories>
                <repository>
                    <id>central</id>
                    <url>http://central</url>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>central</id>
                    <url>http://central</url>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    <activeProfiles>
        <!--make the profile active all the time -->
        <activeProfile>nexus</activeProfile>
    </activeProfiles>
</settings>

关于maven - 在 Idea Intellij 中使用 Nexus 存储库而不是公共(public) Maven,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28063728/

相关文章:

java - 使用gradle将Scala集成到Java中的现有项目中

maven - 如何使用 maven 进行 websphere 7 部署自动化?

java - 将 3rd 方依赖项部署到 Maven 存储库的简单方法

maven - gradle是否使用.m2/settings.xml中的镜像设置

java - Maven 构建失败 : "invalid target release" only in GitLab CI

eclipse - M2E 并让 Maven 生成源文件夹作为 Eclipse 源文件夹

git - 强制 git 自定义 merge 驱动程序以 merge pom.xml (maven) 文件

proxy - Nexus 代理存储库

python - 无法在 docker build 上安装位于私有(private) Nexus 存储库中的 Python 包

maven - 从Gradle发布到Nexus时如何解决此错误