我在构建中添加了一个jetty-maven-plugin
,如下所示:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.16.v20140903</version>
<executions>
<execution>
<id>run-jetty</id>
<goals>
<goal>run</goal>
</goals>
<phase>install</phase>
<configuration>
<webAppSourceDirectory>${basedir}/target/repository/</webAppSourceDirectory>
<webApp>
<contextPath>/site</contextPath>
</webApp>
<!-- run only -->
<scanIntervalSeconds>10</scanIntervalSeconds>
<!-- run-forked only -->
<stopPort>9099</stopPort>
<stopKey>stopPlease</stopKey>
<stopWait>10</stopWait>
<waitForChild>false</waitForChild>
</configuration>
</execution>
</executions>
</plugin>
当我运行周围的 Maven 项目时,Jetty 服务器启动正常,我可以浏览 Web 应用程序 http://localhost:8080/site/
但是,当我将目标run
替换为run-forked
时,我在控制台中得到以下信息:
[INFO] --- jetty-maven-plugin:8.1.5.v20120716:run-forked (run-jetty) @ project ---
[INFO] Configuring Jetty for project: maven-p2
[INFO] Forked process started
然而,没有什么 http://localhost:8080/site/开始。至少那里没有网络应用程序。操作系统在端口 8080(实际上是两个(上报告一个 Java 进程,在 9099 上报告一些东西(我猜是停止处理程序(。
我似乎无法弄清楚如何让run-forked
像run
一样工作(只是在另一个 JVM 中(。我检查了手册中缺少的配置,但找不到任何东西。
mvn jetty:stop
也可以工作,并且不会打印"Jetty不运行!",所以某处有一个Jetty。只是没有网络应用程序。
如何获得run-forked
来启动我的网络应用?
更新Maven插件有效,所以我想这是一个错误:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.25.v20191220</version>
<configuration>
<supportedPackagings>jar</supportedPackagings>
</configuration>
<!-- Rest of config same as above -->
</plugin>
(注意:我需要将supportedPackagings
添加到现有配置中,否则我得到"不支持打包类型 [jar]"。