@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. JAVA - SpringBoot项目跨域访问

    JAVA - SpringBoot添加支持CORS跨域访问 CORS(Cross-Origin Resource Sharing)“跨域资源共享”,是一个W3C标准,它允许浏览器向跨域服务器发送Aja ...

  2. C#重写窗体的方法

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  3. exctern C

    在C++中调用C语言 因为C++扩展了函数重载.编译时会将函数名修改,所以直接条用会出错. #ifdef __cplusplusextern "C" {#endif // __cp ...

  4. NVIDIA TX2--3--NVIDIA Jetson TX2 查看系统版本参数状态及重要指令

    NVIDIA Jetson TX2 查看系统参数状态. 当前博主的TX2更新的版本为:Jetpack 3.3, cuda 9.0.252, cudnn7.0, opencv3.3.1, TensorR ...

  5. Opencv调用深度学习模型

    https://blog.csdn.net/lovelyaiq/article/details/79929393 https://blog.csdn.net/qq_29462849/article/d ...

  6. 第42章 AWR报表的使用

    第42章 AWR报表的使用exec dbms_gather.gather_table_stats('scott','emp');exec dbms_gather_gather_index_stats( ...

  7. HDU_2871 线段树+vecor的中间插入和删除使用

    本来这个题目就是个合并区间的题,就跟Hotel一样,要插入一段,则找左孩子 合并后的中间区间 右孩子,但是比较恶心的是,他需要实时得到某一段的起终点,或者某个点在第几个段里面,我想过在线段树里面加入几 ...

  8. python复习——字符串

    1.字符串:用双引号括起的内容 2.title()——首字母大写:print(变量名.title()) upper()——全部大写:print(变量名.upper()) lower()——全部小写:p ...

  9. Nginx系列p4:进程结构

    Nginx 有两种进程结构:单进程结构,多进程结构.本篇文章我们主要说多进程结构. 问:那为什么 Nginx 采用多进程结构,而不是多线程结构呢? 答:这是因为 Nginx 最核心的目的就是要保证高可 ...

  10. Day 7:TreeSet

    补充上一日:HashCode方法默认返回的是内存地址,String类已经重写了对象的HashCode方法 方法细节:取出数组中的值或字符串的值按照规定计算返回一个值,如果两个字符串内容一致就会返回相同 ...