运行jetty而不使用maven 2插件打包项目

发布于 2024-08-09 20:29:42 字数 231 浏览 4 评论 0原文

我试图在不构建整个项目的情况下运行 jetty,而只需将 jetty 指向目标文件夹下的文件夹。这样做的原因是我希望在为 glassfish 构建应用程序时使用 jetty 作为静态内容服务器。例如,当我对 css 文件进行一点更改时,我不想一直重新部署。

当我使用 maven jetty 插件并运行 jetty:run-exploded 时,它会自动构建项目,包括测试和打包。我希望避免这种情况。

有什么建议吗?

I'm trying to run jetty without building the whole project, but simply point jetty to a folder under the target folder. Reason behind doing this is that I wish to use jetty as a static content server while i build application for glassfish. i don't want to redeploy all the time when i make a little change to a css file, for example.

When I use maven jetty plugin and run jetty:run-exploded, it automatically builds the project including test and package. I wish to avoid that.

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦萦几度 2024-08-16 20:29:42

关于 jetty:run-exploded,文档说:

此目标用于将您的 Web 应用程序组装成爆炸战争并自动将其部署到 Jetty。

...

  • 在执行自身之前调用生命周期阶段package的执行。

因此,您所描述的行为是正常行为,这是有道理的,因为如果尚未构建,jetty 就无法期望在目标下找到某些内容,并且 package 阶段可能涉及诸如过滤之类的事情(因此必须进行过滤)。

也就是说,有一些事情可能会有所帮助(我不确定我是否清楚地理解了你的目标,所以我会提到几个选项)。第一个选项,您可以使用 manual reload 而不是 automatic 以避免自动重新部署。关于手动模式,文档写道:

“手动重新加载” 从 Jetty 6.2.0pre0 开始,将提供控制 Web 应用程序重新部署的新功能。
配置参数为:
<重新加载>[手动|自动]
当设置为手动时,无自动
扫描和重新部署
网络应用程序已完成。相反,用户可以
控制 webapp 何时重新加载
点击回车键。放
自动扫描和
自动重新部署执行于
间隔由控制
scanIntervalSeconds 参数。重载范式的选择也可以
在命令行上配置
使用-Djetty.reload系统
范围。例如:“mvn
-Djetty.reload=manual jetty:run" 将强制手动重新加载,无论
项目pom中配置了什么
同样:“mvn
-Djetty.reload=automatic -Djetty.scanIntervalSeconds=10 jetty:run" 将强制自动
后台重新加载扫一扫
每 10 秒一次,无论
项目pom中的配置。

另一种选择是创建另一个“空”war 模块(在 Maven 意义上)来启动 jetty 并使用 jettyConfig 要设置的可选参数:

除了任何插件配置参数之外还将应用的 jetty.xml 文件的位置。如果您有其他要部署的 web 应用程序、处理程序等,或者您有其他无法从插件配置的 jetty 对象,您可以使用它。

这样,您应该能够从其他 Web 应用程序部署静态内容。我不认为额外的内容会被“观看”,但如果需要,您可以随时将其与手动模式结合起来。虽然从未测试过。

About jetty:run-exploded, the documentation says:

This goal is used to assemble your webapp into an exploded war and automatically deploy it to Jetty.

...

  • Invokes the execution of the lifecycle phase package prior to executing itself.

So the behavior you are describing is the normal behavior and it makes sense as jetty can't expect to find something under target if it hasn't been built and as the package phase could involve things like filtering (so filtering must occur).

That said, a few things might help (I'm not sure I understood clearly your goal so I'll mention several options). First option, you could use manual reload instead of automatic to avoid the automatic redeployment. About the manual mode, the documentation writes:

"Manual Reloading" As of Jetty 6.2.0pre0 a new feature to control webapp redeployment will be available.
The configuration parameter is:
<reload>[manual|automatic]</reload>
When set to manual, no automatic
scanning and redeployment of the
webapp is done. Rather, the user can
control when the webapp is reloaded by
tapping the carriage return key. Set
to automatic the scanning and
automatic redeployment is performed at
intervals controlled by the
scanIntervalSeconds parameter. The choice of reloading paradigm can also
be configured on the command line by
use of the -Djetty.reload system
parameter. For example: "mvn
-Djetty.reload=manual jetty:run" would force manual reloading, regardless of
what is configured in the project pom.
Similarly: "mvn
-Djetty.reload=automatic -Djetty.scanIntervalSeconds=10 jetty:run" will force automatic
background reloading with a sweep
every 10 seconds, regardless of the
configuration in the project pom.

Another option would be to create another "empty" war modules (in the maven sense) to start jetty from and to use the jettyConfig optional parameter to set:

The location of a jetty.xml file that will be applied in addition to any plugin configuration parameters. You might use it if you have other webapps, handlers etc to be deployed, or you have other jetty objects that cannot be configured from the plugin.

This way, you should be able to deploy the static content from the other webapp. I don't think that the additional content will be "watched" but you can always combine it with the manual mode if required. Never tested though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文