有没有办法在 Spring 应用程序中嵌入 Web 服务器?(没有 Spring Boot)

Is there a way to embed a web server in a Spring application? (no Spring Boot)

提问人:André Ferraz 提问时间:11/8/2023 更新时间:11/8/2023 访问量:33

问:

我有一个不使用 Spring Boot 的 Spring 应用程序。我想将此应用程序部署为带有嵌入式 Web 服务器(例如 tomcat)的胖罐子。我可以这样做吗?

当我在谷歌上搜索时,我只找到了与Spring Boot有关的东西。但我没有使用Spring Boot。

Java Spring Tomcat Web 服务器

评论

1赞 M. Deinum 11/8/2023
您可以简单地嵌入 tomcat,但为什么不添加 spring boot 并免费获得呢?为什么要重新发明轮子?
1赞 lane.maxwell 11/8/2023
是的,你可以,但就像之前的评论所说,为什么?有几篇关于如何做到这一点的文章,在谷歌上搜索Spring embedded tomcat without boot
0赞 André Ferraz 11/9/2023
@M.Deinum,这是一个具有许多依赖关系的旧项目。迁移到 Spring Boot 将非常困难。在来这里之前,我实际上尝试过这个。
0赞 André Ferraz 11/9/2023
@lane.maxwell,我试过了这个,但所有搜索结果都说我应该使用spring boot。我想我只会阅读Spring Boot源代码,并了解它们如何在框架中实现这一点。然后,我将该解决方案复制到我的项目中。
0赞 lane.maxwell 11/9/2023
@AndréFerraz 网络上有很多关于如何做到这一点的文章,例如:junjun-java.blogspot.com/2017/06/......

答: 暂无答案