maven工程在Jetty服务器上的自动化部署(开发者模式)
1. 首先你的web
工程必须是一个
maven
工程。
2.
在
maven
工程的
pom
文件中加入
jetty-maven-plugin
插件,以下为
pom
代码示例:
<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>
<groupId>com.malangmedia</groupId>
<artifactId>malangmedia.autoDeployToJetty</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>autoDeployToJetty</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<finalName>autoJetty</finalName>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- 设置war包名称 -->
<finalName>${finalName}</finalName>
<plugins>
<!-- jetty自动部署插件 -->
<!-- scanIntervalSeconds设置的是jetty自动扫描的间隔,单位秒
发现有改动自动更新部署,默认为0,即不扫描管理热部署工程。 -->
<!-- contextPath配置的是部署后文件夹的名字,也即访问的地址。
例:http://localhost:8080/autoJetty -->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.1.v20120215</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppConfig>
<contextPath>/autoJetty</contextPath>
</webAppConfig>
</configuration>
</plugin>
</plugins>
</build>
</project>
3. maven操作命令
打包命令:
mvn install
启动
jetty
:
mvn jetty:run
然后技术人员就只管写代码和查看页面效果,其余的工作交给插件区完成。
4. 当然你也可以再
IDE
中通过
maven
插件来完成命令行测操作
页:
[1]