部署Java Maven项目,以EC2与托盘?托盘、项目、Java、Maven

2023-09-11 09:02:35 作者:雨落轩庭

我不知道究竟如何我会设置起来。我有一个普通的Java / Tomcat的/ MySQL的应用程序,我想部署到EC2。我想用托盘提供包装盒,配置和部署我的战争中。我希望我可以通过一个Maven插件做到这一点?

I'm wondering exactly how I would set this up. I have a normal java/tomcat/mysql app, and I want to deploy to EC2. I'd like to use pallet to provision the box, configure it, and deploy my war there. I'm hoping I can do this via a maven plugin?

我想我的另一种选择是创建一个雷音项目和部署使用相对路径的战争,但我希望能为Maven插件...

I guess my other option is to create a lein project and deploy the war using a relative path, but I'm hoping for the maven plugin...

推荐答案

我不能给你的问题​​的AWS和托盘的一部分说话,但假设你有一个运行Tomcat实例,你可以直接从Maven的使用Apache货物项目部署您的应用程序:

I can't speak to the AWS and Pallet part of your question, but assuming you have a running tomcat instance you can use the Apache Cargo project directly from maven to deploy your app:

下面是我们的货物配置消毒的版本:

Here is a sanitized version of our cargo configuration:

        <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>1.2.1</version>
            <configuration>
              <container>
                <containerId>tomcat6x</containerId>
                <type>remote</type>
              </container>

              <configuration>
                <type>runtime</type>
                <properties>
                    <cargo.hostname>${tomcat.hostname}</cargo.hostname>   
                    <cargo.servlet.port>8080</cargo.servlet.port>
                    <cargo.remote.username>$[tomcat.username}</cargo.remote.username>
                    <cargo.remote.password>${tomcat.password}</cargo.remote.password>
                </properties>
              </configuration>

              <deployer>
                <type>remote</type>
                <deployables>
                  <deployable>
                    <groupId>com.mycompany</groupId>
                    <artifactId>MyWebApp</artifactId>
                    <type>war</type>
                    <pingURL>http://my.company.com/url</pingURL>
                    <pingTimeout>80000</pingTimeout>
                    <properties>
                        <context>ROOT</context>
                    </properties>
                  </deployable>
                </deployables>
              </deployer>
            </configuration>
        </plugin>

您可以再拿到这个运行此命令(设置课程的相关属性):

You can then get this run with this command (set the relevant properties of course):

mvn -DskipTests package cargo:deploy

在使用Apache货物与Maven的更多信息是在这里:的http://船货。codehaus.org / Maven2的+插件+入门+入门

More information on Using Apache Cargo with Maven is here: http://cargo.codehaus.org/Maven2+Plugin+Getting+Started