Adding maven nexus repo to my pom.xml

前端 未结 6 1181
死守一世寂寞
死守一世寂寞 2020-12-08 00:30

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?

6条回答
  •  佛祖请我去吃肉
    2020-12-08 01:10

    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.

    
      ...
      
        
          server001
          my_login
          my_password
          ${user.home}/.ssh/id_dsa
          some_passphrase
          664
          775
          
        
      
      ...
    
    

    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:

    
        ...
        
            acme-nexus-releases
            acme nexus
            https://nexus.acme.net/content/repositories/releases
        
        ...
    
    

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

提交回复
热议问题