nexus maven setting 和pom 文件配置

提交到nexus时候报错:


Downloading: http://nexus.easypeng.lab:8082/nexus/content/repositories/snapshots/com/easypeng/framework/template/framework-template/1.0-SNAPSHOT/maven-metadata.xml
[WARNING] Could not transfer metadata com.easypeng.framework.template:framework-template:1.0-SNAPSHOT/maven-metadata.xml from/to snapshots (http://nexus.easypeng.lab:8082/nexus/content/repositories/snapshots/): Connect to nexus.easypeng.lab:8082 [nexus.easypeng.lab/127.0.0.1] failed: Connection refused: connect
端口号错误

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project framework-template: Failed to deploy artifacts: Could not transfer artifact com.easypeng.framework.template:framework-template:war:1.0-20170721.105730-3 from/to snapshots1 (http://nexus.easypeng.lab:8081/nexus/content/repositories/snapshots/): Failed to transfer file: http://nexus.easypeng.lab:8081/nexus/content/repositories/snapshots/com/easypeng/framework/template/framework-template/1.0-SNAPSHOT/framework-template-1.0-20170721.105730-3.war. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]

setting.xml 和pom.xml 文件的id 不一致


原来是没有配置认证。


maven目录conf的setting.xml里,

  <server>  
    <id>releases</id>  
    <username>admin</username>  
    <password>admin123</password>  
  </server>  
 <server>  
  <id>snapshots</id>  
  <username>admin</username>  
  <password>admin123</password>  
  </server>  
</servers>  

用户名和密码都是nexus的。再次deploy即可。

**注意这里的id要和pom.xml里远程deploy的地址对应一致,我的pom.xml里配置:**

<!-- 配置远程发布到私服,mvn deploy -->  
    <distributionManagement>  
        <repository>  
            <id>releases</id>  
            <name>Nexus Release Repository</name>  
            <url>http://10.1.81.199:8081/nexu
            s/content/repositories/releases/</url>  
        </repository>  
        <snapshotRepository>  
            <id>snapshots</id>  
            <name>Nexus Snapshot Repository</name>  
            <url>http://10.1.81.199:8081/nexus/content/repositories/snapshots/</url>  
        </snapshotRepository>  
    </distributionManagement>  



如果这里不配置,会报错:
报错:Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project Git-demo: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Maven 的 `settings.xml` 文件是用来配置 Maven 的全局设置和本地仓库等信息的,它位于 Maven 安装目录下的 `conf` 目录中。 下面是一个简单的 `settings.xml` 文件示例: ```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"> <localRepository>/path/to/local/repo</localRepository> <mirrors> <mirror> <id>aliyun</id> <mirrorOf>*</mirrorOf> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> </mirror> </mirrors> <profiles> <profile> <id>dev</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <env>dev</env> </properties> <repositories> <repository> <id>central</id> <url>https://repo.maven.apache.org/maven2</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> </profile> <profile> <id>prod</id> <properties> <env>prod</env> </properties> <repositories> <repository> <id>central</id> <url>https://repo.maven.apache.org/maven2</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> </profile> </profiles> <activeProfiles> <activeProfile>dev</activeProfile> </activeProfiles> </settings> ``` 上述示例中,`<localRepository>` 指定了本地 Maven 仓库的路径,`<mirrors>` 配置了阿里云的镜像,`<profiles>` 配置了两个环境的配置信息,`<activeProfiles>` 指定了当前使用的环境。 需要注意的是,`settings.xml` 文件中的配置是全局生效的,如果有多个项目使用同一份配置文件,那么它们都会受到该文件中的配置影响。如果需要针对某个项目单独配置,可以在项目的 `pom.xml` 文件中添加相应的配置
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值