使用Maven部署jar文件和外部资源文件

克里斯544

我是Maven的新手,想通过自动将几个文件和文件夹部署到生产环境来自动化一些构建步骤:

my-app-0.7.0-jar-with-dependencies.jar (main application file)
conf.properties (configuration file that can be edited on the fly)
files_folder (folder that contains html, css etc. that can be edited on the fly)

我的项目结构如下所示:

src
   main 
      java
      resources (contains resources that should be included in the .jar)
conf.properties.jar 
files_folder 

我首先<resources>pom.xml

<resources>
    <resource>
        <directory>.</directory>
        <includes>
            <include>conf.properties</include>
            <include>files_folder/**/*.*</include>
        </includes>
        <targetPath>..</targetPath>
    </resource>
</resources>

这个动作conf.propertiesfiles_foldertarget目录,这是好的(我可以复制的.jar,conf.properties和files_folder并运行它们)。

但是,这些文件不会移动到本地存储库中C:\Users\my_name\.m2\...或外部存储库中(在安装和部署阶段)。

我的想法是,应将这些资源移至存储库,因为:

  • 它们是程序运行所必需的
  • 可以非常快速地回滚到任何以前的版本(只需找到版本文件夹,您需要的所有内容都将在其中;如果不自动将conf.properties和files_folder包含在其中,将不会那么容易)

因此,主要问题是:

  1. 这种思路合理吗?
  2. 如果合理,如何将这些外部资源包括在存储库中?
赫马尔拜兹

Maven是构建工具,而不是部署工具。对于部署到诸如Test,Q&A或Prod之类的环境,其他工具更适合诸如Chef,Puppet,或者可能只是简单的shell脚本等。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章