java Tomcat 支持哪些技术?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2857077/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Which technologies does Tomcat support?
提问by mehdi shahdoost
I read a lot about GlassFish application server that it supports the whole Java EE 6 specification. But which does Tomcat support?
我阅读了很多关于 GlassFish 应用程序服务器的文章,认为它支持整个 Java EE 6 规范。但是Tomcat支持哪些呢?
I know that Tomcat is a JSP/Servlet container, but I see articles in web about "JSF and Tomcat", "Hibernate and Tomcat" and many more.
我知道 Tomcat 是一个 JSP/Servlet 容器,但我在网上看到了关于“JSF 和 Tomcat”、“Hibernate 和 Tomcat”等等的文章。
Can tomcat play with these technologies: EJB, JSF, JPA, Hibernate, Spring, etc..?
tomcat 可以玩这些技术吗:EJB、JSF、JPA、Hibernate、Spring 等..?
回答by BalusC
Tomcat as being a barebones servletcontainer provides indeed only JSP, Servlet, ELand WSAPIs out the box. You can however just provide JSF, JSTL, CDI, JPA, Hibernate, Spring, etc yourself along with the web application in flavor of JAR file(s) in the /WEB-INF/libfolder and some configuration files where necessary.
Tomcat 作为准系统 servletcontainer 确实只提供了JSP、Servlet、EL和WSAPI 开箱即用。但是,您可以自己提供JSF、JSTL、CDI、JPA、Hibernate、Spring等以及文件/WEB-INF/lib夹中 JAR 文件风格的 Web 应用程序和一些必要的配置文件。
EJBis only a story apart since you can't just add "some JARs" to get that to work, but in fact yes, you can put an EJB container on top of Tomcat too if you modify the server core. That's also basically what TomEEhas done. You might as well consider it if your intent is to go Java EE.
EJB只是一个故事,因为您不能仅仅添加“一些 JAR”来使其工作,但事实上,如果您修改服务器核心,您也可以将 EJB 容器放在 Tomcat 之上。这也基本上是TomEE所做的。如果您打算使用 Java EE,不妨考虑一下。
See also:
也可以看看:
回答by Pascal Thivent
I read a lot about GlassFish application server that it supports the whole Java EE 6 specification. But which does Tomcat support?
我阅读了很多关于 GlassFish 应用程序服务器的文章,认为它支持整个 Java EE 6 规范。但是Tomcat支持哪些呢?
Tomcat (which is not the RI of the Servlet spec anymore since Java EE 5) doesn't support anyof the Java EE 6 APIs out of the box. In its latest version, Tomcat 6 ships with:
Tomcat(自 Java EE 5 起不再是 Servlet 规范的 RI)不支持任何开箱即用的 Java EE 6 API。在最新版本中,Tomcat 6 附带:
- Servlet 2.5
- JSP 2.1/EL 2.1
- 小服务程序 2.5
- JSP 2.1/EL 2.1
While the "web" part of GlassFish implements:
GlassFish 的“web”部分实现:
- Java Servlet 3.0
- JavaServer Faces 2.0
- JavaServer Pages 2.2/Expression Language 2.2
- Standard Tag Library for JavaServer Pages (JSTL) 1.2
- Java Servlet 3.0
- JavaServer Faces 2.0
- JavaServer Pages 2.2/表达式语言2.2
- JavaServer Pages (JSTL) 1.2 的标准标记库
Can tomcat play with these technologies: EJB, JSF, JPA, Hibernate, Spring, etc..?
tomcat 可以玩这些技术吗:EJB、JSF、JPA、Hibernate、Spring 等..?
You can use some of them by packaging them inside your application (this articlehas a nice summary):
您可以通过将它们打包到您的应用程序中来使用其中的一些(本文有一个很好的总结):
- EJB 3.1: no, there is no standalone EJB 3.1 container at the time of writing this (and if you consider using EJB, use a real Java EE server, Tomcat with a standalone EJB container is not an equivalent, especially from a Transaction Manager point of view).
- JSF 2.0 and EL 2.2: yes, possible with some pain
- CDI 1.0: yes, possible
- Bean validation 1.0: yes possible with JSF 2.0 and JPA
- JPA 2.0: yes, possible but you'll have to obtain the EntityManager yourself and to manage transaction yourself (or to use a third party container like Spring).
- EJB 3.1:不,在撰写本文时没有独立的 EJB 3.1 容器(如果您考虑使用 EJB,请使用真正的 Java EE 服务器,带有独立 EJB 容器的 Tomcat 不是等效的,尤其是从事务管理器的角度来看观点)。
- JSF 2.0 和 EL 2.2:是的,可能会有一些痛苦
- CDI 1.0:是的,可能
- Bean 验证 1.0:可以使用 JSF 2.0 和 JPA
- JPA 2.0:是的,可能,但您必须自己获取 EntityManager 并自己管理事务(或使用第三方容器,如 Spring)。
But let me insist: whatever you'll add to Tomcat, you won't get an equivalent of a Java EE 6 container, even if we just compare with a Web Profile implementation (like GlassFish v3 Web Profile): no EJB 3.1 Lite, no JTA 1.1, no descriptor-less applications, etc.
但是让我坚持:无论您将添加到 Tomcat 中,您都不会获得 Java EE 6 容器的等效项,即使我们只是与 Web Profile 实现(如GlassFish v3 Web Profile)进行比较:没有 EJB 3.1 Lite,没有 JTA 1.1,没有无描述符应用程序等。
If you have the choice, my suggestion would to use GlassFish v3 Web Profile and to embrace Java EE 6.
如果可以选择,我的建议是使用 GlassFish v3 Web Profile 并采用 Java EE 6。
回答by sonara
I found the table on the tomcat page helpful. Page: http://tomcat.apache.org/whichversion.html
我发现 tomcat 页面上的表格很有帮助。页面:http: //tomcat.apache.org/whichversion.html


回答by mindas
Tomcat is not an EJB container, therefore you should use full blown JavaEE 6 server for that (such as Glassfish, Websphere, Weblogic, etc.).
Tomcat 不是 EJB 容器,因此您应该为此使用成熟的 JavaEE 6 服务器(例如 Glassfish、Websphere、Weblogic 等)。
Tomcat can use Spring/Hibernate as this only requires relevant jars and configs/context definitions. Same applies for JSF.
Tomcat 可以使用 Spring/Hibernate,因为这只需要相关的 jars 和 configs/context 定义。这同样适用于 JSF。
JPA is an abstract spec, and Hibernate (along others) is an implementation of this spec, therefore the answer is "yes, it can be implemented on Tomcat".
JPA 是一个抽象规范,而 Hibernate(以及其他规范)是该规范的一个实现,因此答案是“是的,它可以在 Tomcat 上实现”。
回答by stacker
Tomcat supports depending on it's version:
Tomcat 支持取决于它的版本:
JSTL 1.0 : Servlet 2.3 : JSP 1,2 (tomcat 4)
JSTL 1.1 : Servlet 2.4 : JSP 2.0 (tomcat 5)
JSTL 1.2 : Servlet 2.5 : JSP 2.1 (tomcat 6)
That tomcat offers no EJB support by default has already be answered. EasyBeanscovers this issue.
已经回答了 tomcat 默认不提供 EJB 支持。 EasyBeans涵盖了这个问题。
To include JSF 1.2 in tomcat6 there is a tutorial
要在 tomcat6 中包含 JSF 1.2,有一个教程
EDIT: Unfortunately there is no single dependency(/compatibility) matrix out there. JPA is an API, which is implemented by i.g. Hibernate. It should not be hard to find out which versions match. And yes they can be used with Tomcat (besides) Spring.
编辑:不幸的是,那里没有单一的依赖(/兼容性)矩阵。JPA是一个API,由ig Hibernate实现。找出哪些版本匹配应该不难。是的,它们可以与 Tomcat(除了)Spring 一起使用。

