将Maven nexus存储库添加到我的pom.xml [英] Adding maven nexus repo to my pom.xml

查看:97
本文介绍了将Maven nexus存储库添加到我的pom.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在本地计算机上安装了nexus.我希望我的pom文件指向此存储库.如何将自定义存储库添加到pom.xml文件?

解决方案

来自 Maven-设置参考

用于下载和部署的存储库由POM的repositoriesdistributionManagement元素定义.但是,某些设置(例如用户名和密码)不应与pom.xml一起分发.这种类型的信息应存在于构建服务器的settings.xml中.

<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>server001</id>
      <username>my_login</username>
      <password>my_password</password>
      <privateKey>${user.home}/.ssh/id_dsa</privateKey>
      <passphrase>some_passphrase</passphrase>
      <filePermissions>664</filePermissions>
      <directoryPermissions>775</directoryPermissions>
      <configuration></configuration>
    </server>
  </servers>
  ...
</settings>

id:这是服务器的ID(不是登录用户的ID),与Maven尝试连接的存储库/镜像的ID元素匹配.

用户名和密码:这些元素成对出现,表示验证该服务器所需的登录名和密码.

privateKey,密码::与前两个元素一样,该对指定到私钥的路径(默认为${user.home}/.ssh/id_dsa)和密码(如果需要).将来,密码短语和密码元素可能会被外部化,但是现在必须在settings.xml文件中将其设置为纯文本.

filePermissions,directoryPermissions :在部署中创建存储库文件或目录时,这些权限即为使用权限.每个文件的合法值是一个三位数,与* nix文件的许可权相对应. 664或775.

注意:如果您使用私钥登录服务器,请确保省略该元素.否则,密钥将被忽略.

您需要做的只是idusernamepassword

idURL应该在您的pom.xml中定义,如下所示:

<repositories>
    ...
    <repository>
        <id>acme-nexus-releases</id>
        <name>acme nexus</name>
        <url>https://nexus.acme.net/content/repositories/releases</url>
    </repository>
    ...
</repositories>

如果您需要服务器的用户名和密码,则应对其进行加密. Maven密码加密

I have installed nexus on my local machine. I want my pom file to point to this repo. How can I add my custom repository to my pom.xml file?

解决方案

From Maven - Settings Reference

The repositories for download and deployment are defined by the repositories and distributionManagement elements of the POM. However, certain settings such as username and password should not be distributed along with the pom.xml. This type of information should exist on the build server in the settings.xml.

<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>server001</id>
      <username>my_login</username>
      <password>my_password</password>
      <privateKey>${user.home}/.ssh/id_dsa</privateKey>
      <passphrase>some_passphrase</passphrase>
      <filePermissions>664</filePermissions>
      <directoryPermissions>775</directoryPermissions>
      <configuration></configuration>
    </server>
  </servers>
  ...
</settings>

id: This is the ID of the server (not of the user to login as) that matches the id element of the repository/mirror that Maven tries to connect to.

username, password: These elements appear as a pair denoting the login and password required to authenticate to this server.

privateKey, passphrase: Like the previous two elements, this pair specifies a path to a private key (default is ${user.home}/.ssh/id_dsa) and a passphrase, if required. The passphrase and password elements may be externalized in the future, but for now they must be set plain-text in the settings.xml file.

filePermissions, directoryPermissions: When a repository file or directory is created on deployment, these are the permissions to use. The legal values of each is a three digit number corrosponding to *nix file permissions, ie. 664, or 775.

Note: If you use a private key to login to the server, make sure you omit the element. Otherwise, the key will be ignored.

All you should need is the id, username and password

The id and URL should be defined in your pom.xml like this:

<repositories>
    ...
    <repository>
        <id>acme-nexus-releases</id>
        <name>acme nexus</name>
        <url>https://nexus.acme.net/content/repositories/releases</url>
    </repository>
    ...
</repositories>

If you need a username and password to your server, you should encrypt it. Maven Password Encryption

这篇关于将Maven nexus存储库添加到我的pom.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆