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

<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>

之后mvn deploy即可上传源代码和jar


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wp500

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值