码迷,mamicode.com
首页 > 编程语言 > 详细

Spring注解说明

时间:2018-07-10 00:36:08      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:condition   style   ioc   window   pre   net   标记   ring   加载   

 @scope("singleton")

#什么都不传是singleto是单实例,容器启动的时候创建对象,放到IOC中,用到的时候到IOC中获取,

#如果传prototype表示是多实例,容器启动的时候不创建对象,在调用的时候创建容器到IOC中。且调用一次创建一次。

@bean

public Student student(){

return new Student();

}

 

2.懒加载

@lazy

容器启动不创建对象,调用的时候创建对象

@lazy

@bean

public Student student(){

return new Studnet();

}

@Conditional({WindowConditional.class})
WindowConditional 实现condition接口,返回true

如果注解标记在类上,纳米是true类中的对象才会加入到容器中,如果标记在方法上,方法中的对象才会放到容器中。

 

Spring注解说明

标签:condition   style   ioc   window   pre   net   标记   ring   加载   

原文地址:https://www.cnblogs.com/sz-jack/p/9286711.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!