maven 打包 releases 和 snapshots 版本

releases:线上版本(生产环境使用的)

snapshots:快照版本(开发过程中使用的)

maven 打包代码到私服根据version 后面是否带有“-SNAPSHOTS” 来区分是打包线上版本还是快照版本,如果带有“-SNAPSHOTS”  打包快照版本,否则即为线上版本

  1. 定义version 使用占位符
  2. 在properties中设置默认version
  3. 在profiles 中 根据不同的profile设置不同的versionpom配置
  4. mvn deploy 打包使用 默认版本 ; mvn deploy -p Prod 打包设置版本
  5. <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>com.boloni</groupId>
        <artifactId>appollo-gfs-parent</artifactId>
        <version>${project.release.version}</version>
        <packaging>pom</packaging>
    
        <name>appollo-gfs-parent</name>
        <url>http://www.xxxxx.com</url>
        <description>liuchao9186@126.com</description>
    
    
        <properties>
            <project.release.version>0.1-SNAPSHOT</project.release.version>
        </properties>
    
        <profiles>
            <profile>
                <id>prod</id>
                <properties>
                    <project.release.version>0.1</project.release.version>
                </properties>
            </profile>
        </profiles>
        <distributionManagement>
            <repository>
                <id>releases</id>
                <url>http://xxxxxx:8070/nexus/content/repositories/releases</url>
            </repository>
            <snapshotRepository>
                <id>snapshots</id>
                <url>http://xxxxx:8070/nexus/content/repositories/snapshots</url>
            </snapshotRepository>
        </distributionManagement>
    </project>
    

     

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
搭建本地maven中央仓库的详细步骤如下: 1. 下载并安装Nexus 在Nexus官网下载最新的Nexus OSS,安装并启动。 2. 配置Nexus 打开Nexus的管理控制台,在左侧导航栏中选择Repositories,然后点击Create repository按钮,创建一个仓库。选择Hosted repository类型,命名为maven-releases(用于存储发布版本),再次点击Create repository按钮创建仓库。同样的方式,创建一个命名为maven-snapshots的Hosted repository类型的仓库(用于存储快照版本)。 3. 配置Maven的settings.xml文件 在Maven的conf目录下找到settings.xml文件,在文件中添加如下配置: ``` <mirrors> <mirror> <id>nexus</id> <mirrorOf>*</mirrorOf> <url>http://localhost:8081/repository/maven-public/</url> </mirror> </mirrors> <repositories> <repository> <id>maven-releases</id> <url>http://localhost:8081/repository/maven-releases/</url> </repository> <repository> <id>maven-snapshots</id> <url>http://localhost:8081/repository/maven-snapshots/</url> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <servers> <server> <id>maven-releases</id> <username>admin</username> <password>admin123</password> </server> <server> <id>maven-snapshots</id> <username>admin</username> <password>admin123</password> </server> </servers> ``` 其中,mirrors用于指定Maven使用Nexus作为镜像源,repositories用于指定Nexus仓库的地址和名称,servers用于指定连接Nexus仓库的用户名和密码。 4. 发布项目到本地仓库 在项目的pom.xml文件中添加如下配置: ``` <distributionManagement> <repository> <id>maven-releases</id> <url>http://localhost:8081/repository/maven-releases/</url> </repository> <snapshotRepository> <id>maven-snapshots</id> <url>http://localhost:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement> ``` 然后使用Maven的deploy命令将项目发布到本地仓库中: ``` mvn deploy ``` 这样,项目就会被发布到maven-releases或maven-snapshots仓库中。 至此,本地maven中央仓库的搭建就完成了。可以通过访问Nexus的web界面来查看已经发布到仓库中的项目

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

全栈行动派

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

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

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

打赏作者

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

抵扣说明:

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

余额充值