Maven项目集成Jetty

1、新建webapp maven项目。

项目目录结构如下。

2、pom文件添加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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.coshaho</groupId>
  <artifactId>spring-mvc-demo</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>spring-mvc-demo Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>spring-mvc-demo</finalName>
    <plugins>
      <plugin>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>9.4.15.v20190215</version>
        <configuration>
          <scanIntervalSeconds>10</scanIntervalSeconds>
          <httpConnector>
            <port>8080</port>
          </httpConnector>
          <webApp>
            <contextPath>/coshaho</contextPath>
          </webApp>
        </configuration>
      </plugin>
    </plugins> 
  </build>
</project>

3、cmd执行mvn jetty:run命令。运行结果如下。

 

posted @ 2019-03-11 20:55  coshaho  阅读(3968)  评论(0编辑  收藏  举报