Maven 目標 - liberty:deploy
您可以利用 liberty:deploy 目標,將應用程式部署到 Liberty 伺服器中。
liberty:deploy 目標會將指定的應用程式部署到 Liberty 伺服器的 dropins/ 目錄。伺服器必須存在,且在執行中。
參數
下表說明 deploy 目標的參數。
參數 | 說明 | 必要 |
---|---|---|
serverHome | Liberty 伺服器安裝架構的目錄位置。 | 是,只在未設定 assemblyArchive 和 assemblyArtifact 參數之時。 |
assemblyArchive | Liberty 伺服器壓縮保存檔的位置。這個保存檔會解壓縮到 installDirectory 參數所指定的目錄中。 | 是,只在未設定 serverHome 和 assemblyArtifact 參數之時。 |
assemblyArtifact | Liberty 伺服器組合的 Maven 構件名稱。組合會安裝到 installDirectory 參數所指定的目錄中。如需 Liberty 伺服器 Maven 組合的相關資訊,請參閱安裝為 Maven 構件。 | 是,只在未設定 serverHome 和 assemblyArchive 參數之時。 |
installDirectory | 當利用組合保存檔或構件選項來安裝 Liberty 伺服器時,該伺服器的本端安裝目錄位置。預設值為 ${project.build.directory} /liberty。 | 否 |
refresh | 如果是 true,則將 Liberty 伺服器重新安裝到本端目錄中。只有在利用組合保存檔或構件選項來安裝伺服器時,才使用這個參數。 預設值為 false。 | 否 |
serverName | Liberty 伺服器實例的名稱。預設值為 defaultServer。 | 否 |
appArchive | 要部署之應用程式檔案的位置。 應用程式類型可以是 war、ear、rar、eba、zip 或 jar。 | 是,如果未設定 appArtifact 參數的話。 |
appArtifact | 要部署之應用程式的 Maven 構件名稱。 應用程式類型可以是 war、ear、rar、eba、zip 或 jar。從 liberty-maven-plugin 1.1 版開始。 | 是,如果未設定 appArchive 參數的話。 |
timeout | 等待確認部署已順利完成的時間上限(毫秒)。 預設值為 40 秒。 | 否 |
- 範例:部署應用程式
- 這是可以在產品的 pom.xml 檔中使用的程式碼 Snippet。
<build> ... <plugins> <plugin> <groupId>com.ibm.websphere.wlp.maven.plugins</groupId> <artifactId>liberty-maven-plugin</artifactId> <version>1.0</version> <executions> ... <execution> <id>deploy-app</id> <phase>pre-integration-test</phase> <goals> <goal>deploy</goal> </goals> <configuration> <appArchive>HelloWorld.war</appArchive> </configuration> </execution> ... </executions> <configuration> <serverHome>/opt/ibm/wlp</serverHome> <serverName>test</serverName> </configuration> </plugin> </plugins> ... </build>
- 範例:從指令行部署應用程式
- 這個 Maven 指令可用來將應用程式部署到伺服器。
mvn liberty:deploy -DserverHome=/opt/ibm/wlp -DserverName=test -DappArchive=/tmp/HelloWorld.war