1、@Service用于标注业务层组件 
       2、@Controller用于标注控制层组件(如struts中的action) 
       3、@Repository用于标注数据访问组件,即DAO组件. 
       4、@Component泛指组件,当组件不好归类的时候,我们可以使用这个注解进行标注。    
           @Service public class UserServiceImpl implements UserService { } 
           @Repository public class UserDaoImpl implements UserDao { } getBean的默认名称是类名(头字母小写),如果想自定义,可以@Service(“***”)               这样来指定,这种bean默认是单例的,如果想改变,可以使用@Service(“beanName”) 
           @Scope(“prototype”)来改变。可以使用以下方式指定初始化方法和销毁方法(方法名任意): @PostConstruct public void init() { }
posted on 2017-12-28 09:57  巨象  阅读(122)  评论(0编辑  收藏  举报