Maven配置文件-开发与生产 [英] Maven profiles - dev vs production

查看:78
本文介绍了Maven配置文件-开发与生产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇如何设置开发与生产Maven配置文件.我应该只将快照存储库放在开发配置文件中,而其他工件(本地存储库,发行版等)还是在生产配置文件中?

I was curious about how to set up development vs production maven profiles. Should I only put the snapshots repo in the dev profile, and the other artifacts (local repo, for releases etc), in the production profile?

这些类型的配置文件有哪些主要区别?

What are the major things which different profiles of these types?

推荐答案

显然,主要区别是Prod,Test和Dev配置文件之间的设置.像

The major difference is, obviously, settings among Prod, Test, and Dev profiles. Things like

  • 数据库连接
  • 资源设置,线程池配置,日志文件位置及其大小之类的属性
  • 存储设置(例如本地存储)可能具有/mnt/media,但对于Prod,则可能需要S3
  • Database connectivity
  • Properties like resource settings, thread-pool configuration, log file location and it's size
  • Storage settings like for local you might have a /mnt/media but for Prod, you may want S3

这些配置文件中的变量.

varies in these profiles.

现在发布了,通常测试配置文件具有SNAPSHOT发行版(如夜间构建),该发行版被配置为转到您的SNAPSHOT存储库.通常使用Maven Release Plugin发行Prod配置文件,该文件会自动将SNAPSHOT退出发行版本/工件.并配置为将工件存储在RELEASES回购中.这些存储库的配置类似于

Now come to release, usually Test profile/s has SNAPSHOT releases (like nightly builds) that is configured to go to SNAPSHOT repository of yours. And a Prod profile is released, usually, using Maven Release Plugin, that automatically knocks the SNAPSHOT off your release version/artifacts. And is configured to store the artifact in RELEASES repo. The configuration for these repos goes like

    <profile>
        <id>test</id>
        <distributionManagement>
            <snapshotRepository>
                <id>snapshotrepo</id>
                <name>Repository for snapshots only</name>
                <layout>default</layout>
                <uniqueVersion>false</uniqueVersion>
                <url>http://repo.company.com/snapshots</url>
            </snapshotRepository>
        </distributionManagement>
        .....
        .....
        .....

    <profile>
        <id>prod</id>
        </distributionManagement>
            <repository>
                <id>releaserepo</id>
                <name>Final release artifacts</name>
                <layout>default</layout>
                <uniqueVersion>false</uniqueVersion>
                <url>http://repo.company.com/releases</url>
            </repository>
        </distributionManagement>
        ....
        ....

这些存储库的凭证进入 settings.xml .

The credential to these repos goes into settings.xml.

Dev配置文件通常没有配置为发布到公司存储库(因为它会杂乱无用的工件),它只是安装在本地存储库中,如SNAPSHOT并在每个版本中被覆盖.

Dev profile is usually not configured to release to company repo (as it will be too cluttered of useless artifacts), it just gets installed in your local repo, as SNAPSHOT and overwritten on each build.

这篇关于Maven配置文件-开发与生产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆