Spring Framework是否附带自己的bean? [英] Does Spring Framework come with its own beans?

查看:213
本文介绍了Spring Framework是否附带自己的bean?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本文来自名为Core Java Server Faces的书:

This text is from the book called Core Java Server Faces:


这是一个历史事故,有两个独立的机制,
CDI bean和JSF托管bean,适用于可在JSF
页面中使用的bean。我们建议你使用CDI bean,除非你的应用程序必须
在一个普通的servlet运行器上工作,比如Tomcat。
书的源代码有两个版本,一个带有CDI bean(用于Java EE 6
应用程序服务器),另一个带有JSF托管bean(用于没有CDI支持的servlet
runners)。

It is a historical accident that there are two separate mechanisms, CDI beans and JSF managed beans, for beans that can be used in JSF pages. We suggest that you use CDI beans unless your application must work on a plain servlet runner such as Tomcat. The source code for the book comes in two versions, one with CDI beans (for Java EE 6 application servers) and one with JSF managed beans (for servlet runners without CDI support).

我的问题是:

如果我使用Spring Framework,一个Tomcat服务器,我需要使用上面提到的bean之一,还是Spring Framework自带的bean实现?

If I use the Spring Framework, and a Tomcat Server, will I need to use one of the beans mentioned above, or does Spring Framework come with its own bean implementations?

据我所知,Spring Framework支持依赖注入。如果我在Tomcat上运行应用程序,它是否支持它?这是否意味着我既不使用CDI bean也不使用本书中提到的JSF Managed方法?

As far as I know, Spring Framework supports Dependency Injection. Does it support it if I run the application on Tomcat? Does it mean that I will be using neither the CDI beans nor the JSF Managed means mentioned in this book?

谢谢。

推荐答案

谈论容器比bean实现更正确。是Spring带有自己的容器。事实上,你可以看到spring框架作为完整Java EE堆栈的一种替代。

talking about container is more correct than bean implementation. Yes Spring comes with its own container. In fact you can see spring frameworks as a kind of alternative to the full Java EE stack.

一起使用Spring DI和CDI没有兴趣,但你仍然可以使用JSF虽然如果我建议你在这种情况下切换到Java EE 6 Web配置文件服务器而不是spring。

Using Spring DI and CDI together has about no interest but you still can use JSF with spring on tomcat although if i would advise you to switch to a Java EE 6 web profile server instead of spring in this case.

Spring带来的是自己的视图框架实现命名为spring mvc。

Spring comes with is own view framework implementation named spring mvc.

所有这些都可以在任何servlet容器(jetty tomcat等等)上完美运行,前提是你提供了相关的依赖关系。

All of this can run perfectly on any servlet container (jetty tomcat etc...) on condition that you provide associated dependencies ofc.

这篇关于Spring Framework是否附带自己的bean?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆