Maven Jetty 插件
此示例适用于 maven 项目。添加 jetty-maven-plugin 以构建元素,如下所示。
<build>
   <plugins>
      <plugin>
         <groupId>org.eclipse.jetty</groupId>
         <artifactId>jetty-maven-plugin</artifactId>
         <version>9.4.0.M0</version>
      </plugin>
   </plugins>
</build>
执行 mvn jetty:run
它下载必要的依赖项并启动 jetty 服务器。如果服务器已启动,控制台将显示以下行 -
[INFO] Started ServerConnector@7a31eb5d{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
[INFO] Started @10535ms
[INFO] Started Jetty Server
可以在 http:// localhost:8080 /中 访问应用程序
如果你想在不同的端口开始 -
在启动期间使用系统属性
mvn -Djetty.http.port=8181 jetty:run
或永久添加到插件配置
<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>9.4.0.M0</version>
  <configuration>
     <httpConnector>
       <port>8181</port>
     </httpConnector>
  </configuration>
</plugin>