@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 ...
随机推荐
- T_SQL 将一列多行数据合并为一行
SQL Server在进行数据迁移和报表处理的时候会遇到将一列多行数据拼接为一个字符串的情况,为了处理这个问题,在网上找了一些相关的资料,提供两种方法,供遇到类似问题的朋友们参考,也借此加深自己的印象 ...
- Python MySQL Select
章节 Python MySQL 入门 Python MySQL 创建数据库 Python MySQL 创建表 Python MySQL 插入表 Python MySQL Select Python M ...
- input防抖动
input及时搜索,输入一个字符就去处理请求数据.但是还没有输入完就开始频繁请求,进行处理 <body> <input id="put"/> </bo ...
- Http协议Get与Post请求
摘要:https://blog.csdn.net/kebi007/article/details/103059900 不就是get拼接url,post传body,get限制字符串长度吗! 请求缓存:G ...
- 【LeetCode】分发糖果
[问题]老师想给孩子们分发糖果,有 N 个孩子站成了一条直线,老师会根据每个孩子的表现,预先给他们评分. 你需要按照以下要求,帮助老师给这些孩子分发糖果: 每个孩子至少分配到 1 个糖果.相邻的孩子中 ...
- k8s CI/CD--Jenkinsfile例子
试用k8s内部jenkins,并且配置好podtemplate pipeline{ agent any stages{ stage('get the code'){ steps{ ...
- 3 react 简书 添加 头部搜索动态效果
1. 添加动态效果组件 yarn add react-transition-group 2. 修改 src/common/header/index.js import React, {Componen ...
- Transaction Managament(事务管理二、Spring事务)
Transaction Managament(事务管理二.Spring事务) Spring事务框架的优势 Spring事务框架将开放过程中事务管理相关的关注点进行了分离,对这些关注点进行了抽象分离 ...
- loback.xml 在idea中代码自动完成
1.下载xsd文件 2.idea添加xsd文件 URI: http://ch.qos.logback/xml/ns/logback File: D:\env\plugins\logback\logba ...
- PAT A1018
A 1018 Public Bike Management 这个题目算是比较典型的一个.我分别用dfs,及dijkstra+dfs实现了一下. dfs实现代码: #include <cstdio ...