Spring学习:类的自动检测及bean的注册(注解)

来源:互联网 发布:苹果mac os x操作系统 编辑:程序博客网 时间:2024/06/04 07:01

1.可以被自动发现并注册的类的条件:

     加了@Component 、@Repository、@Service、@Controller这四个注解或者自定义的继承自@Component的注解的类

       @Component是一个通用的注解

       @Repositroy用于注解Dao层

       @Service 用于注解Service层

       @Controller 用于注解Controller层

2.<context:  component-scan  base-package="包名" />


0 0
原创粉丝点击