maven系列(二):maven之项目到私服上传下载配置

一、上传

1、maven的settings.xml中 添加

	<server>
	  <!-- 私服中仓库名称-->
      <id>releases</id>
	  <!-- 私服登录名-->
      <username>admin</username>
	  <!-- 私服登录密码-->
      <password>admin123</password>
    </server>
	<server>
	  <!-- 私服中仓库名称-->
      <id>snapshots</id>
	  <!-- 私服登录名-->
      <username>admin</username>
	  <!-- 私服登录密码-->
      <password>admin123</password>
    </server>

2、项目pom添加

	<distributionManagement>
		<!--id要和私服中配置的server名字一致-->
		<repository>
			<id>releases</id>
			<name>User Project Release</name>
			<url>http://ip:port/nexus/content/repositories/releases/</url>
		</repository>

		<snapshotRepository>
			<id>snapshots</id>
			<name>User Project SNAPSHOTS</name>
			<url>http://ip:port/nexus/content/repositories/snapshots/</url>
		</snapshotRepository>
	</distributionManagement>

	<build>
		<plugins>
			<!-- 要将源码放上去,需要加入这个插件 -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-source-plugin</artifactId>
				<configuration>
					<attach>true</attach>
				</configuration>
				<executions>
					<execution>
						<phase>compile</phase>
						<goals>
							<goal>jar</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

3、依此执行maven的clean,compile,package,deploy命令

注意:每次发布时 注意jar版本号(pom中version)

二、下载

1、

<dependency>
	<groupId>上传到私服项目的groupId</groupId>
	<artifactId>上传到私服项目的artifactId</artifactId>
   <version>上传到私服项目的version</version>
</dependency>

    <repositories>
        <repository>
            <id>local-nexus</id>
            <name>Maven Repository Switchboard</name>
            <layout>default</layout>
            <url>http://ip:port/nexus/content/groups/public/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>nexus</id>
            <name>local private nexus</name>
            <url>http://localhost:8084/nexus/content/groups/public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值