一. 在jetty上远程部署并调试maven工程

来源:互联网 发布:java手机游戏开发 编辑:程序博客网 时间:2024/04/29 23:30

1. 下载、安装jetty

http://blog.csdn.net/guoyankun/article/details/38319689

2. 使用cargo完成远程部署

2.1. 在jetty中部署cargo-jetty-7-and-onwards-deployer

2.1.1.下载cargo-jetty-7-and-onwards-deployer:cargo-jetty-7-and-onwards-deployer-1.4.13-2.war

2.1.2. 修改cargo-jetty-7-and-onwards-deployer

参考:http://cargo.codehaus.org/Jetty+Remote+Deployer?print=1

注:依靠web.xml中<login-config><realm-name>指定的名字在jetty-web.xml中查找realm,参考http://www.tuicool.com/articles/ryiA3y

2.1.3 部署cargo-jetty-7-and-onwards-deployer到$(jetty.home)/webapps/cargo-jetty-deployer

2.2. 在maven工程中添加remote deploy的支持

同样参考http://cargo.codehaus.org/Jetty+Remote+Deployer?print=1,但要注意一下几点

2.2.1. 需要在$(home)/.m2/settings.xml中添加一条pluginGroup进pluginGroups,否则下载不到该plugin

    <pluginGroups>
        <pluginGroup>org.codehaus.cargo</pluginGroup>
    </pluginGroups>

2.2.2. maven工程的pom.xml,build参考如下配置

<build>

<plugins>

<plugin>

<groupId>org.codehaus.cargo</groupId>

<artifactId>cargo-maven2-plugin</artifactId>

<version>1.4.9</version>

<configuration>

<container>

<containerId>jetty9x</containerId>

<type>remote</type>

</container>


<configuration>

<type>runtime</type>

<properties>

<cargo.hostname>xxx.xxx.xxx.xxx</cargo.hostname>

<cargo.servlet.port>8080</cargo.servlet.port>

<cargo.remote.username>manager</cargo.remote.username>

<cargo.remote.password>manager</cargo.remote.password>

</properties>

</configuration>


<deployer>

<type>remote</type>

</deployer>


<deployables>

<deployable>

<groupId>com.2109.kitchen</groupId>

<artifactId>mobilegw</artifactId>

<type>war</type>

<properties>

<context>/mobilegw</context>

</properties>

</deployable>

</deployables>

</configuration>

</plugin>

</plugins>

</build>

2.2.3. mvn cargo:deploy过程中由于超时间隔过小,容易造成deploy不成功的情况,修改超时间隔在${jetty.home}/start.d/http.ini中。

2.2.4. mvn cargo:redeploy用于重新部署,他会删除老的,部署新的

3. 为jetty开启远程调试

java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 -Xnoagent -jar start.jar &

4. eclipse上远程调试工程

Debug Configurations => Remote Java Application => New:修改host和port指向jetty开启的调试地址(上例中端口为8000)


以上为远程部署,远程调试jetty容器下运行的java app的全过程

0 0
原创粉丝点击