如何实现持续部署的Web服务 [英] How to implement continuous deployment for a web service

查看:312
本文介绍了如何实现持续部署的Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java应用程序,它运行Web容器(码头的那一刻)内,通过网络服务响应请求。

I have a Java application, which runs inside web container (Jetty at the moment) and responds to requests via web services.

现在我想建立一种机制,它允许部署(WAR文件传输到服务器,安装新版本有)应用到Amazon EC2实例的新版本尽可能容易地(理想 - 通过运行一些Maven的命令)。

Now I want to create a mechanism, which allows to deploy (transfer the WAR file to the server, install the new version there) a new version of the application to Amazon EC2 instance as easily as possible (ideally - by running some Maven command).

我使用魔豆我的版本控制和他们提供部署支持,但我无法弄清楚如何将其应用到我的方案。

I'm using Beanstalk for my version control and they offer deployment support, but I couldn't figure out how to apply it to my scenario.

有没有关于如何部署Web应用程序到Amazon EC2与Maven(含或不含青苗)任何教程?

Are there any tutorials on how to deploy web applications to Amazon EC2 with Maven (with or without Beanstalk) ?

更新1(2013年10月4日):青苗工作人员推荐我使用<一个href="http://support.beanstalkapp.com/customer/portal/articles/361135-how-do-i-setup-ssh-deployments-"相对=nofollow> SSH部署。

Update 1 (10.04.2013): Beanstalk staff has recommended me to use SSH deployments.

2更新(2013年11月4日23点17 MSK):

在我使用Maven插件的货物第一次尝试,我加了下面的东西到我的的pom.xml

In my first attempt to use Maven Cargo plugin, I added following stuff to my 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货:部署,得到下面的输出:

Then I ran mvn cargo:deploy and got following output:

[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的问题:

2 questions:

  1. 我怎样才能解决这个问题?
  2. 在哪里可以指定地址我的Tomcat容器?

更新3(2013年4月12日22:36 MSK):

我改变有关货物的插件像这样的内容:

I changed the section related to Cargo plugin like this:

    <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货:部署并得到了这样的输出:

Then I executed mvn cargo:deploy and got this output:

[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]

更新4(2013年4月12日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>

然后,我用下面的命令来部署我的应用程序到服务器:

Then, I used following commands to deploy my application to the server:

  1. MVN清洁
  2. MVN安装
  3. MVN货:部署
  1. mvn clean
  2. mvn install
  3. mvn cargo:deploy

请注意,&LT;包装&GT; 必须为了这个序列的工作设置为(否则你可能会得到奇怪的错误信息)。

Please note that <packaging> must be set to war in order for this sequence to work (otherwise you may get strange error messages).

推荐答案

请纠正我,如果我错了。我知道你正在使用的 Tomcat的版本7 。该配置的Tomcat 7 应如下: -

Please correct me if I'm wrong. I understand that you're using the Tomcat version 7. The Cargo configuration for Tomcat 7 should be as the following: -

<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>

请注意,

  1. &LT; cargo.hostname&GT; 是远程主机名或IP地址
  2. &LT; cargo.protocol&GT; HTTP HTTPS
  3. &LT; cargo.servlet.port&GT; 远程端口根据在&LT; cargo.protocol&GT; ,例如: 8080或8443
  4. &LT;背景&GT; 上下文名称部署网络时使用应用程序。
  1. <cargo.hostname> is the remote host name or ip address.
  2. <cargo.protocol> is either http or https.
  3. <cargo.servlet.port> is the remote port based on the <cargo.protocol>, e.g. 8080 or 8443
  4. <context> is the context name to use when deploying the web application.

请参阅货物:Tomcat的7.x的和的 Maven2的插件参考指南了解更多信息

Please refer to Cargo: Tomcat 7.x and Maven2 Plugin Reference Guide for further information.

我希望这可以帮助。

这篇关于如何实现持续部署的Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆