Users are sometimes unsure whether a BeanFactory
or an ApplicationContext
is best suited for use in a particular situation. A BeanFactory
pretty much just instantiates and configures beans. An ApplicationContext
also does that, and it provides the supporting infrastructure to enable lots of enterprise-specific features such as transactions and AOP.
In short, favor the use of an ApplicationContext
.
The org.springframework.beans
and org.springframework.context
packages provide the basis for the Spring Framework's IoC container. The BeanFactory interface provides an advanced configuration mechanism capable of managing objects of any nature. The ApplicationContextinterface builds on top of the BeanFactory
(it is a sub-interface) and adds other functionality such as easier integration with Spring's AOP features, message resource handling (for use in internationalization), event propagation, and application-layer specific contexts such as theWebApplicationContext
for use in web applications.
In short, the BeanFactory
provides the configuration framework and basic functionality, while the ApplicationContext
adds more enterprise-centric functionality to it. The ApplicationContext
is a complete superset of the BeanFactory
, and any description of BeanFactory
capabilities and behavior is to be considered to apply to the ApplicationContext
as well.
This chapter is divided into two parts, with the first part covering the basic principles that apply to both the BeanFactory
and ApplicationContext
, and with the second part covering those features that apply only to the ApplicationContext
interface
ApplicationContext提供了更多的方法
分享到:
相关推荐
Not Using Commons Logging ................................................................... 12 Using SLF4J ..............................................................................................
Not Using Commons Logging ................................................................... 12 Using SLF4J ..............................................................................................
java dubbo admin 2.5.3 + jdk 1.7 亲试 好用 ... java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext 这个异常消息是说 BeanFactory 对象没有初始化或已经关闭了,使用 ApplicationContext 获取 ...
// swap arr[i+1] and arr[high] (or pivot) int temp = arr[i + 1]; arr[i + 1] = arr[high]; arr[high] = temp; return i + 1; } } ``` **输入n个整数,输出其中最小的k个** 这个问题可以通过构建一个...