商讯信箱
用户名: @
密  码:   注册|忘记密码
登录
个人用户经销商
您的位置:首页 > 技术频道 > 正文

元素名

 

元素类型

 

说明

 

默认值

 

取值说明

 

aliases

 

String[]

 

Bean的别名

 

{}

 

 

dependencyCheck

 

DependencyCheck

 

默认依赖检查方式

 

DependencyCheck. UNSPECIFIED 即不进行依赖检查

 

 

allowOverriding

 

boolean

 

允许覆盖xml或其它Configurationbean

 

false

 

 

autowire

 

AutoWire

 

自动织入方式

 

INHERITED

 

Autowire

 

dependsOn

 

String[]

 

当前Bean依赖的bean

 

{}

 

 

destroyMethodName

 

String

 

销毁方法名

 

 

 

initMethodName

 

String

 

初始化方法名

 

 

 

lazy

 

Lazy

 

延时初始化策略

 

UNSPECIFIED

 

 

meta

 

Meta []

 

当前bean的元数据

 

{}

 

 

scope

 

String

 

Bean的作用域

 

singleton

 

Singleton,prototype或自定义作用域

 

    使用纯java方式的bean定义时,处理静态方法时,不再需要-Factory-method
@Bean public ExampleBean exampleBean() { return ExampleFactory.createBean(); } 当用方法来定义一个Bean时,这个方法必须是public的。 示例:使用aliases元素。,定义一个Bean,别名为hello @Bean(aliases={"hello"}) public HelloWorld helloWorld(){ HelloWorld helloWorld = new HelloWorld(); helloWorld.setWord(word()); return helloWorld; } public static void main(String[] args){ ApplicationContext context = new AnnotationApplicationContext(ConfigurationFull.class.getName()); HelloWorld hello = (HelloWorld)context.getBean("hello"); hello.sayHello(); }
1 2 3 4 5 6 7 8 9 10 11 12
【内容导航】
第1页: 第1页 第2页: 第2页
第3页: 第3页 第4页: 第4页
第5页: 第5页 第6页: 第6页
第7页: 第7页 第8页: 第8页
第9页: 第9页 第10页: 第10页
第11页: 第11页 第12页: 第12页
©版权所有。未经许可,不得转载。
[责任编辑:赵恒]