作用域
- singleton:(默认 )单例,在一个bean容器中只存在一份
- prototype:每次请求(每次使用)创建新的实例,destory方式不生效
- request:每次Http请求创建一个实例且仅在当前request内生效
- session:同上,在session内生效
- global session:基于portlet的Web中生效,如果在web,基于session
singleton作用域
package cn.itcast.hello;
public class Hello {
}
base4.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframewor