spring学习---2013-08-07
?Lifecycle callbacks
InitializingBean and DisposableBean interfaces.
The container calls
afterPropertiesSet() for the former and destroy() for the latter to allow the bean to perform
certain actions upon initialization and destruction of your beans.
不要和prototype一起用
Initialization callbacks
<bean id="exampleInitBean" init-method="init"/>
public class ExampleBean {public void init() {// do some initialization work}}
?
...is exactly the same as...
<bean id="exampleInitBean" name="code"><bean id="exampleInitBean" destroy-method="cleanup"/>public class ExampleBean {public void cleanup() {// do some destruction work (like releasing pooled connections)}}
?
...is exactly the same as...
<bean id="exampleInitBean" name="code"><beans default-init-method="init"><bean id="blogService" ref="blogDao" /></bean></beans>
?
The presence of the default-init-method attribute on the top-level <beans/> element attribute
causes the Spring IoC container to recognize a method called init on beans as the initialization method
callback.
Where existing bean classes already have callback methods that are named at variance with the
convention, you can override the default by specifying (in XML, that is) the method name using the
init-method and destroy-method attributes of the <bean/> itself.
?
?
?
?
?
Annotation-based container configuration
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"<!--不带前缀的 标签 到="http://www.springframework.org/schema/beans"对的xsd文件中找-->xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsd"><context:annotation-config/></beans>
?.xsd文件(元数据文件) 定义xml文件语法 ?控制了能在这个xml文件里出现的元素
一个xml文件 可以引入多个xsd
在myeclipse 的xml catalog中配置 否则会到网上找 速度慢。。
schemaLocation
xmlns:xml name space
?
?