@Component@Service@Controller@Repository是spring注解,注解后可以被spring框架所扫描并注入到spring容器来进行管理 
@Component是通用注解,其他三个注解是这个注解的拓展,并且具有了特定的功能 
@Repository注解在持久层中,具有将数据库操作抛出的原生异常翻译转化为spring的持久层异常的功能。 
@Controller层是spring-mvc的注解,具有将请求进行转发,重定向的功能。 
@Service层是业务逻辑层注解,这个注解只是标注该类处于业务逻辑层。 
用这些注解对应用进行分层之后,就能将请求处理,义务逻辑处理,数据库操作处理分离出来,为代码解耦,也方便了以后项目的维护和开发。

Spring 注释 @Autowired 和@Resource 的区别

@Autowired和@Resource都可以用来装配bean,都可以写在字段上,或者方法上。

@Autowired属于Spring的;@Resource为JSR-250标准的注释,属于J2EE的。

@Component, @Repository, @Service,@Controller的区别的更多相关文章

  1. SpringAnnotation注解之@Component,@Repository,@Service,@Controller

    @Component:组件,表示此写上了此注解的bean,作为一个组件存在于容器中.这样的话别的地方就可以使用@Resource这个注解来把这个组件作为一个资源来使用了.初始化bean的名字为类名首字 ...

  2. @Component @Repository @Service @Controller

    Spring 2.5 中除了提供 @Component 注释外,还定义了几个拥有特殊语义的注释,它们分别是:@Repository.@Service 和 @Controller.在目前的 Spring ...

  3. 从头认识Spring-2.7 自己主动检測Bean(1)-@Component @Repository @Service @Controller

    这一章节我们来讨论一下自己主动检測Bean. 1.domain 厨师类: package com.raylee.my_new_spring.my_new_spring.ch02.topic_1_19; ...

  4. 【转载】@Component, @Repository, @Service的区别

    @Component, @Repository, @Service的区别 官网引用 引用spring的官方文档中的一段描述: 在Spring2.0之前的版本中,@Repository注解可以标记在任何 ...

  5. [转]what’s the difference between @Component ,@Repository & @Service annotations in Spring

    原文地址:https://www.cnblogs.com/softidea/p/6070314.html @Component is equivalent to <bean> @Servi ...

  6. What's the difference between @Component, @Repository & @Service annotations in Spring?

    @Component is equivalent to <bean> @Service, @Controller , @Repository = {@Component + some mo ...

  7. @Repository , @Service , @Controller 和 @Component

    用Spring MVC时@Controller注解的类将变成一个Spring MVC的控制器. 不用Spring MVC的情况下, 这四个注解没有区别. 根据注解的语义, 注解在类上面可以提高代码的可 ...

  8. @Component, @Repository, @Service的区别

    注解 含义 @Component 最普通的组件,可以被注入到spring容器进行管理 @Repository 作用于持久层 @Service 作用于业务逻辑层 @Controller 作用于表现层(s ...

  9. Spring-Boot-Bean的使用,@Repository,@Service,@Controller,@Component

    前言 在Spring MVC的时候,我们使用xml来配置bean,如今的Spring boot推荐我们使用元注解的发生,那就听Spring Boot的推荐,下面我就为大家来介绍下Spring Boot ...

随机推荐

  1. Swift 元组 Tuple

    let infoArray:[Any] = ["jack",18,1.88] let infoName=infoArray[0] as!String //此处为Any类型强转为St ...

  2. sql server C#操作。原文在收藏页面

    C#操作SQL Server数据库   1.概述 2.连接字符串的写法 3.SqlConnection对象 4.SqlCommand对象 5.SqlDataReader对象 6.DataSet对象 7 ...

  3. Python 加载mnist、cifar数据

    import tensorflow.examples.tutorials.mnist.input_data mnist = input_data.read_data_sets("MNIST_ ...

  4. 使用jackson转换类型时报Unrecognized field

    调用 objectMapper.convertValue(obj, valueType ); 时报错 原因 obj 的属性多于 valueType 导致,添加一条语句即可 objectMapper.c ...

  5. .Net 题目

    1.简述public.private.protected.Internal修饰符的访问权限 public:公共成员,完全公开,没有访问限制. private:私有成员,在类的内部才可以访问. prot ...

  6. 自学Java第五章——《面向对象的基本特征》

    面向对象的基本特征: 1.封装 2.继承 3.多态 6.1 封装 1.好处: (1)隐藏实现细节,方便使用者使用 (2)安全,可以控制可见范围 2.如何实现封装? 通过权限修饰符 面试题:请按照可见范 ...

  7. Python基础+爬虫基础

    Python基础+爬虫基础 一.python的安装: 1.建议安装Anaconda,会自己安装一些Python的类库以及自动的配置环境变量,比较方便. 二.基础介绍 1.什么是命名空间:x=1,1存在 ...

  8. 吴裕雄--天生自然Django框架开发笔记:Django Nginx+uwsgi 安装配置

    Django Nginx+uwsgi 安装配置 使用 python manage.py runserver 来运行服务器.这只适用测试环境中使用. 正式发布的服务,需要一个可以稳定而持续的服务器,比如 ...

  9. SQL inner join, join, left join, right join, full outer join

    基本信息 创建两个表a1, a2. 两个表的重要差别是:a1 中有5,'wu',a2中没有. a2中有 4,'li',而a1中没有. 创建表和插入数据的代码如下: -- 创建a1表 create ta ...

  10. Tensorflow——用openpose进行人体骨骼检测

    https://blog.csdn.net/eereere/article/details/80176007 参考资料code:https://github.com/ildoonet/tf-pose- ...