当前位置:编程学习 > 网站相关 >>

maven常用命令备忘

将工程打包,发布到远程仓库中的方法

首先设置setting.xml

在<servers>...</servers>中添加一个节点元素<server></server>

如:

    <server>
      <id>nx-snapshots</id>
      <username>xxx</username>
      <password>xxx</password>
    </server>
指定一个用户名/密码

设置pom.xml

添加要发布的服务器信息

<distributionManagement>
<repository>
<id>nx-releases-deploy</id>   此处与setting.xml中设置的server id 一致标识使用设置的用户名/密码验证发布的权限
  <name>Internal Releases</name>
<url>http://111.111.11.11:8088/nexus/content/repositories/thirdparty</url>
</repository>
</distributionManagement>


如果:在使用的时候出现,返回400的错误。原因是nexus仓库设置有问题。

如下操作可以解决:

进入nexus管理员界面。点击3rd party 下面 configuration标签下。 找到deployment policy 选项。之前选择的是disable redeploy 这样不可以重复发布,修改为allow redeploy即可。

  使用deployment用户进行设置setting.xml <server>元素 该用具有上传权限。


2. 发布源代码

需要使用 maven-source-plugin插件

设置pom.xml


[html] 
<project> 
... 
    <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-source-plugin</artifactId> 
        <version>2.2.1</version> 
        <configuration> 
            <attach>true</attach> 
        </configuration> 
        <executions> 
            <execution> 
                <phase>compile</phase>         
                <!-- 在compile阶段中执行 --> 
                <goals> 
                    <goal>jar</goal> 
                </goals> 
            </execution> 
        </executions> 
    </plugin> 
... 
</project> 

补充:综合编程 , 其他综合 ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,