@Component, @Repository, @Service,@Controller的区别
@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的区别的更多相关文章
- SpringAnnotation注解之@Component,@Repository,@Service,@Controller
@Component:组件,表示此写上了此注解的bean,作为一个组件存在于容器中.这样的话别的地方就可以使用@Resource这个注解来把这个组件作为一个资源来使用了.初始化bean的名字为类名首字 ...
- @Component @Repository @Service @Controller
Spring 2.5 中除了提供 @Component 注释外,还定义了几个拥有特殊语义的注释,它们分别是:@Repository.@Service 和 @Controller.在目前的 Spring ...
- 从头认识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; ...
- 【转载】@Component, @Repository, @Service的区别
@Component, @Repository, @Service的区别 官网引用 引用spring的官方文档中的一段描述: 在Spring2.0之前的版本中,@Repository注解可以标记在任何 ...
- [转]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 ...
- What's the difference between @Component, @Repository & @Service annotations in Spring?
@Component is equivalent to <bean> @Service, @Controller , @Repository = {@Component + some mo ...
- @Repository , @Service , @Controller 和 @Component
用Spring MVC时@Controller注解的类将变成一个Spring MVC的控制器. 不用Spring MVC的情况下, 这四个注解没有区别. 根据注解的语义, 注解在类上面可以提高代码的可 ...
- @Component, @Repository, @Service的区别
注解 含义 @Component 最普通的组件,可以被注入到spring容器进行管理 @Repository 作用于持久层 @Service 作用于业务逻辑层 @Controller 作用于表现层(s ...
- Spring-Boot-Bean的使用,@Repository,@Service,@Controller,@Component
前言 在Spring MVC的时候,我们使用xml来配置bean,如今的Spring boot推荐我们使用元注解的发生,那就听Spring Boot的推荐,下面我就为大家来介绍下Spring Boot ...
随机推荐
- 使用HttpURLConnection方式访问接口
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import ...
- Flink on yarn以及实现jobManager 高可用(HA)
on yarn https://ci.apache.org/projects/flink/flink-docs-release-1.8/ops/deployment/yarn_setup.html f ...
- C#使窗体不显示在任务栏
this.ShowInTaskbar = false;///使窗体不显示在任务栏
- Spark 集群 任务提交模式
Spark 集群的模式及提交任务的方式 本文大致的内容图 Spark 集群的两种模式: Standalone 模式 Standalone-client 任务提交方式 提交命令 ./spark-subm ...
- Apache NiFi Processor实战
1 前言 Apache NiFi是什么?NiFi官网给出如下解释:“一个易用.强大.可靠的数据处理与分发系统”.通俗的来说,即Apache NiFi 是一个易于使用.功能强大而且可靠的数据处理和分发系 ...
- Java8 新特性_Lambda 表达式
1. Java8新特性_简介 Lambda 表达式 函数式接口 方法引用与构造器引用 Stream API 接口中的默认方法与静态方法 新时间日期 API 减少空指针异常的容器 Optional 2. ...
- 线段树&树状数组与离散化的妙用
牛客2019多校联盟Day7 Fine the median 题意: 每次给数组插入区间[Li,Ri] 内的所有数,每操作一次查询中位数. 遇到这题真的算是巧合,然而就是这种冥冥之中的缘分,给了我线 ...
- caffe 官方demo python api
Jupyter https://nbviewer.jupyter.org/github/BVLC/caffe/blob/master/examples/net_surgery.ipynb 涉及: - ...
- windows driver 写数据到txt
HANDLE hFile; OBJECT_ATTRIBUTES oa; IO_STATUS_BLOCK iosb; LARGE_INTEGER li; UNICODE_STRING strPath = ...
- EUI库 - 9 - 数据集合 - 数据容器
DataGroup 设置一个数据源 自动创建内部所需的对象 来完成数据展示 还要设置单条数据的模板 叫ItemRenderer 继承关系 eui.List eui.ListBase e ...