[英]Deploying a jar file and external resource files with Maven
我是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
。
我首先在pom.xml
添加<resources>
元素
<resources>
<resource>
<directory>.</directory>
<includes>
<include>conf.properties</include>
<include>files_folder/**/*.*</include>
</includes>
<targetPath>..</targetPath>
</resource>
</resources>
這會將conf.properties
和files_folder
移到target
目錄,這很好(我可以復制.jar,conf.properties和files_folder並運行它們)。
但是,這些文件不會移動到C:\\Users\\my_name\\.m2\\...
或外部存儲庫中的本地存儲庫中(在安裝和部署階段)。
我的想法是,應將這些資源移至存儲庫,因為:
因此,主要問題是:
像其他響應一樣,我建議您需要考慮一種持續集成方法。 我以前在Jenkins上有很好的經驗。 它是免費的,並具有很多功能。 它還擁有一個開發了一系列插件的大型社區:
https://wiki.jenkins-ci.org/display/JENKINS/Meet+Jenkins
根據您要部署的內容以及您希望如何部署它,一些可能對您的過程有幫助的插件是:
您可以將這些文件保留在src / main / resources / META-INF中,而不是將這些文件保留在類路徑中。 因此,當您使用Maven構建項目時,並且如果已將包裝選擇為ear <artifactId>ProjectName</artifactId> <version>Version</version> <packaging>ear</packaging>
那么所有這些文件都將打包在jar中,並將在您的maven存儲庫中可用
Maven是構建工具,而不是部署工具。 對於部署到諸如Test,Q&A或Prod之類的環境,其他工具則更適合諸如Chef,Puppet,或者可能只是一個簡單的shell腳本等。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.