mvn备忘

创建web工程

mvn archetype:generate -DgroupId=com.malangmedia -DartifactId=autoDeployToJetty  -DarchetypeArtifactId=maven-archetype-webapp -Dversion=1.0

添加jetty插件

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

打包命令: mvn install

启动 jetty : mvn jetty:run

posted @ 2012-07-05 22:21  meetrice  阅读(198)  评论(0编辑  收藏  举报