在一个类上面注释了@service是什么意思?我刚学的。大家帮我说一下原理,谢谢

解决方案 »

  1.   

    是说这个类是一个service,这个是JPA的概念,提供各种服务的一个类,其实在spring中应该和@bean没啥两样
      

  2.   

    这是spring2.5之后出现的注解,就跟在spring配置文件里配置bean差不多的功能,就是让spring自动扫描管理组件,@Service  @Controller @Repository @Component ,这四个其实是一样的功能,没有区别,只是在MVC模式上表示的层不一样,service一般标注在service层的bean上,controller标注在控制层,@Repository标注在view层,component通用
      

  3.   

    使用此注解需要在spring配置文件里加上这个<context:component-scan base-package=""/>
      

  4.   

    就是用注解的方式把这个类注入到spring配置中...
      

  5.   

    这是spring2.5之后出现的注解,就跟在spring配置文件里配置bean差不多的功能,就是让spring自动扫描管理组件,@Service @Controller @Repository @Component ,这四个其实是一样的功能,没有区别,只是在MVC模式上表示的层不一样,service一般标注在service层的bean上,controller标注在控制层,@Repository标注在view层,component通用。使用此注解需要在spring配置文件里加上这个<context:component-scan base-package=""/>