【问题标题】:How to add remote Maven repository in IntelliJ Idea?如何在 IntelliJ Idea 中添加远程 Maven 存储库?
【发布时间】:2019-11-30 05:52:52
【问题描述】:

我需要向我的 Maven 项目添加一些外部依赖项。例如我需要这个库:https://packages.atlassian.com/content/repositories/atlassian-public/com/atlassian/jira/jira-rest-java-client-core/5.1.0/ 我正在努力添加这个库所在的存储库。

我已经尝试过: - 将https://packages.atlassian.com/content/repositories/atlassian-public 添加到设置 -> 构建、执行、部署 -> 远程 Jar 存储库 -> Maven Jar 存储库 - 按照本教程 http://maven.apache.org/settings.html#Repositories 将存储库添加到 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">
<profiles>
    <profile>
        <id>testname</id>
        <repositories>
            <repository>
                <id>atlassianReleases</id>
                <name>Atlassian Releases</name>
                <releases>
                    <enabled>true</enabled>
                    <updatePolicy>always</updatePolicy>
                    <checksumPolicy>warn</checksumPolicy>
                </releases>                  
                <url>https://packages.atlassian.com/content/repositories/atlassian-public</url>
            </repository>
        </repositories>
    </profile>
</profiles>

<activeProfiles>
    <activeProfile>testname</activeProfile>
</activeProfiles>

</settings>
  • 通过设置更新添加的存储库 -> 构建、执行、部署 -> Maven -> 存储库
  • pom.xml 上的人民币 -> Maven -> 重新导入
  • 重建项目

当然,我的 pom.xml 中有正确的依赖关系:

<dependency>
    <groupId>com.atlassian.jira</groupId>
    <artifactId>jira-rest-java-client-core</artifactId>
    <version>5.1.0</version>
</dependency>

我仍然收到使用的包不存在的错误消息。

编辑: 我注意到在我的本地存储库中,我有 com\atlassian\jira\jira-rest-java-client-core\5.1.0 文件夹,但只有 .pom 文件、_remote.repositories 和 .pom.sha1 文件。

编辑2: 问题是我的VPN设置引起的,解决了。

【问题讨论】:

  • 你是否在 Build, Execution, Deployment -> Maven -> “User settings file” 字段下设置 settings.xml 文件路径并覆盖它?
  • settings.xml 的路径是正确的,无论是否勾选覆盖复选框,我仍然得到相同的结果。

标签: java maven intellij-idea maven-3


【解决方案1】:

首先您必须删除 .m2 目录中的 com\atlassian\jira\jira-rest-java-client-core 文件夹
并再次运行 mvn 命令。
*在 intellij 中,如果您更改了 pom.xml 文件,maven 插件会再次自动运行

【讨论】:

  • 我仍然只得到 .pom 文件、_remote.repositories 和 .pom.sha1 文件。
  • 我可以看看你的 pom.xml 文件吗?
  • 很遗憾没有,因为公司 NDA。它只是包含更多的依赖项,没有什么不寻常的。
  • 在 Settings -> Build, Execution, Deployment -> Remote Jar Repositories -> Maven Jar Repositories 中设置的 url 末尾设置 '/'
【解决方案2】:

将此添加到您的 pom.xml repositories 部分:

<repository>
        <id>atlassian-public</id>
        <url>https://packages.atlassian.com/mvn/maven-external/</url>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
            <checksumPolicy>warn</checksumPolicy>
        </snapshots>
        <releases>
            <enabled>true</enabled>
            <checksumPolicy>warn</checksumPolicy>
        </releases>
</repository>

在此处查看文档https://developer.atlassian.com/server/framework/atlassian-sdk/atlassian-maven-repositories-2818705/

【讨论】:

    猜你喜欢
    • 2011-12-30
    • 1970-01-01
    • 1970-01-01
    • 2015-11-09
    • 2014-11-22
    • 2016-02-16
    • 2012-05-27
    • 2016-05-05
    • 2012-05-12
    相关资源
    最近更新 更多