我有一個Java應用程序,它運行在Web容器(Jetty當前)內並通過Web服務響應請求。如何實現Web服務的連續部署
現在我想創建一個機制,它允許儘可能輕鬆地部署(將WAR文件傳輸到服務器,在那裏安裝新版本)應用程序的新版本到最新版本(理想情況下 - 通過運行一些Maven命令)。
我爲我的版本控制使用Beanstalk,他們提供部署支持,但我無法弄清楚如何將其應用於我的方案。
是否有任何關於如何使用Maven(帶或不帶Beanstalk)將Web應用程序部署到Amazon EC2的教程?
更新1(2013年4月10日):魔豆的工作人員建議我使用SSH deployments。
更新2(二〇一三年十一月四日23:17 MSK):
我在第一次使用Maven插件貨物的嘗試,我加了下面的東西我pom.xml
:
<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>
[...]
<build>
[...]
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<container>
<containerId>Heaven7</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.username>myusername</cargo.remote.username>
<cargo.remote.password>mypassword</cargo.remote.password>
</properties>
</configuration>
<!-- Deployer configuration -->
<deployer>
<type>remote</type>
</deployer>
<deployables>
<deployable>
<groupId>ru.mycompany</groupId>
<artifactId>my-product</artifactId>
<type>war</type>
</deployable>
</deployables>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
然後我跑mvn cargo:deploy
,並得到了以下的輸出:
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.3.3:dep
oy (default-cli) on project [...]: Execution default-cli of goal org.codeh
us.cargo:cargo-maven2-plugin:1.3.3:deploy failed: Cannot create configuration.
here's no registered configuration for the parameters (container [id = [Heaven7
, type = [remote]], configuration type [runtime]). Actually there are no valid
ypes registered for this configuration. Maybe you've made a mistake spelling it
2個問題:
- 我該如何解決它?
- 我在哪裏可以指定我的Tomcat容器的地址?
更新3(2013年4月12日22:36 MSK):
我改變有關貨物插件這樣的部分:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.3.3</version>
<configuration>
<container>
<containerId>tomcat7</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.username>myuser</cargo.remote.username>
<cargo.remote.password>mypassword</cargo.remote.password>
<cargo.hostname>ec2-NN-NNN-NN-NN.compute-1.amazonaws.com</cargo.hostname>
<cargo.protocol>http</cargo.protocol>
<cargo.servlet.port>8080</cargo.servlet.port>
</properties>
</configuration>
<!-- Deployer configuration -->
<deployer>
<type>remote</type>
</deployer>
<deployables>
<deployable>
<groupId>ru.mycompany</groupId>
<artifactId>myproduct</artifactId>
<type>war</type>
</deployable>
</deployables>
</configuration>
</plugin>
</plugins>
然後我執行mvn cargo:deploy
,並得到了這個輸出:
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.3.3:depl
oyer-deploy (default-cli) on project ccp-server: Execution default-cli of goal o
rg.codehaus.cargo:cargo-maven2-plugin:1.3.3:deployer-deploy failed: Cannot creat
e configuration. There's no registered configuration for the parameters (contain
er [id = [tomcat7], type = [remote]], configuration type [runtime]). Actually th
ere are no valid types registered for this configuration. Maybe you've made a mi
stake spelling it? -> [Help 1]
Update 4(12.04.2013 23:12):
我改變pom.xml
再次:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.3.3</version>
<configuration>
<container>
<containerId>tomcat7x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.username>myuser</cargo.remote.username>
<cargo.remote.password>mypassword</cargo.remote.password>
<cargo.hostname>ec2-NN-NNN-NN-NN.compute-1.amazonaws.com</cargo.hostname>
<cargo.protocol>http</cargo.protocol>
<cargo.servlet.port>8080</cargo.servlet.port>
</properties>
</configuration>
<!-- Deployer configuration -->
<deployer>
<type>remote</type>
</deployer>
<deployables>
<deployable>
<groupId>ru.mycompany</groupId>
<artifactId>myproduct</artifactId>
<type>war</type>
</deployable>
</deployables>
</configuration>
</plugin>
然後,我用下面的命令來我的應用程序部署到服務器:
mvn clean
mvn install
mvn cargo:deploy
請注意,<packaging>
必須設置爲war
才能使此序列正常工作(否則您可能會收到奇怪的錯誤消息)。
感謝您的回答。我試過了,你可以在上面的「更新3」中看到結果。 – 2013-04-12 18:40:16
如果我錯了,請糾正我。在我回答的時候,更新3使用了tomcat7而不是tomcat7x。 – 2013-04-13 00:56:22
由於StackOverflow法規的限制,我現在不能授予您賞金。請等2小時。 – 2013-04-13 07:43:59