DP_*_*DP_ 5 amazon-ec2 amazon-web-services maven-3 maven continuous-deployment
我有一个Java应用程序,它在Web容器(Jetty目前)内运行,并通过Web服务响应请求.
现在我想创建一个机制,允许尽可能容易地部署(将WAR文件传输到服务器,在那里安装新版本)应用程序的新版本到达Amazon EC2实例(理想情况下 - 通过运行一些Maven命令) .
我正在使用Beanstalk进行版本控制,它们提供了部署支持,但我无法弄清楚如何将其应用到我的场景中.
有没有关于如何使用Maven(有或没有Beanstalk)将Web应用程序部署到Amazon EC2的教程?
更新1(10.04.2013): Beanstalk工作人员建议我使用SSH部署.
更新2(2013年4月11日23:17 MSK):
在我第一次尝试使用Maven Cargo插件时,我向我添加了以下内容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>
Run Code Online (Sandbox Code Playgroud)
然后我跑了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
Run Code Online (Sandbox Code Playgroud)
2个问题:
更新3(12.04.2013 22:36 MSK):
我更改了与Cargo插件相关的部分,如下所示:
<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>
Run Code Online (Sandbox Code Playgroud)
然后我执行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]
Run Code Online (Sandbox Code Playgroud)
更新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>
Run Code Online (Sandbox Code Playgroud)
然后,我使用以下命令将我的应用程序部署到服务器:
mvn clean
mvn install
mvn cargo:deploy
请注意,<packaging>
必须设置war
为此顺序才能正常工作(否则您可能会收到奇怪的错误消息).
如果我错了,请纠正我。我了解到您正在使用Tomcat version 7
. 配置Cargo
应Tomcat 7
如下所示:-
<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>myusername</cargo.remote.username>
<cargo.remote.password>mypassword</cargo.remote.password>
<cargo.hostname>MY_HOST</cargo.hostname>
<cargo.protocol>http</cargo.protocol>
<cargo.servlet.port>SERVER_PORT</cargo.servlet.port>
</properties>
</configuration>
<!-- Deployer configuration -->
<deployer>
<type>remote</type>
<deployables>
<deployable>
<groupId>ru.mycompany</groupId>
<artifactId>my-product</artifactId>
<type>war</type>
<properties>
<context>MY_CONTEXT</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
请注意
<cargo.hostname>
是远程主机名或 IP 地址。<cargo.protocol>
是http
或https
。<cargo.servlet.port>
是remote port
基于的<cargo.protocol>
,例如8080或8443<context>
是context name
部署 Web 应用程序时使用的。请参阅Cargo:Tomcat 7.x和Maven2 插件参考指南以获取更多信息。
我希望这会有所帮助。
归档时间: |
|
查看次数: |
2409 次 |
最近记录: |