如何使用jetty嵌入spring mvc应用程序

发布于 2024-10-16 20:05:54 字数 518 浏览 8 评论 0原文

我有一个正在运行的 Spring MVC 应用程序(在部署到 jboss 时执行我想要的所有操作),现在我正在寻找一种如何从 jar 启动我的应用程序的方法。我的想法是,在启动 jar 时,首先应该启动某种 Web 服务器以便能够运行该应用程序。

我尝试了很多与jetty的组合(已经损失了大约2天),但每一个都失败了,大部分建议来自https://stackoverflow.com/tags/embedded-jetty/hot

我的主要弱点是我对 servlet、上下文等没有真正透彻的了解。我在浏览谷歌搜索时经常看到的术语,也许我已经找到了解决方案,但不理解它。

有人做过类似的事情吗?是的,我对 tomcat 提出了类似的问题:

Maven tomcat 插件

I have a working Spring MVC application(doing everything I wanted when deployed to jboss) and now I'm looking a way how to start my application from a jar. What I've though of is when starting jar, first some kind of web server should be started in order to be able to run the application.

And I've tried like a tons of combinations with jetty(lost about 2 days already), and I failed every one of them, mostly suggestions from https://stackoverflow.com/tags/embedded-jetty/hot

My main weakness is that I don't really have thorough understanding of servlets, contexts and so on. Terms which I see on a regular basis while browsing google search, maybe I found a solution already but didn't understand it.

Has anyone done something similar? And yes I've asked similar question for tomcat :

Maven tomcat plugin

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

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

发布评论

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

评论(1

请你别敷衍 2024-10-23 20:05:54

是的,我已经做过好几次这样的事情了,如果你知道这些位是如何工作的,那就相当简单了。

既然您已经解释过您不知道这些位是如何工作的,那么这会有点困难:)
但它们并不太难学,而且最简单的学习方法就是实践 - 所以你正在走上正确的道路。

这里接受的答案:可执行的war文件,在没有maven的情况下启动jetty 是您将获得的有关此主题的一些最佳建议。

我建议:

  1. 首先创建一个 WAR(您可能从 JBoss 部署中获得该 WAR)
  2. 在标准 Jetty 下运行该 WAR(相当简单,有很多教程)
  3. 然后按照我链接到的建议操作,将嵌入式 Jetty 转变为嵌入式 Jetty到你的 WAR 文件中。

如果您遇到任何问题,请提出具体问题并提供问题的具体示例,我们将尽力提供帮助。

Yes, I've done this sort of this several times, and it's fairly straight forward if you know how the bits work.

Since you've explained that you don't know how the bits work, that's going to be a bit harder :)
But they're not too hard to learn, and the easiest way to learn is by doing - so you're heading down the right path.

The accepted answer here: Executable war file that starts jetty without maven is some of the best advice you're going to get on this topic.

I would suggest:

  1. Create a WAR to start with (which you probably have from your JBoss deployment)
  2. Get that WAR running under standard Jetty (fairly straight forward, with lots of tutorials around)
  3. Then follow the advice I linked to, to turn embedded Jetty into your WAR file.

If you run into any issues, ask specific questions with specific examples of what went wrong, and we'll try and help out.

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