Spring 部分常用注解
最近在Spring-MVC的项目,把一些自己在项目中使用到的注解整理一下。
1、@Controller
2、@Component
把普通 POJO 实例化到 Spring 容器中;
3、@Scope
声明范围类型,值有:singleton、prototype、request、session、global session;
4、@Service
对应业务层的Bean;
5、@Repository
对应数据访问层Bean;
6、@Recource
JDK注解;按照name或者type方式注入对象,默认按照name方式;
7、@Autowired
Spring注解;按照type方式注入对象;
8、@Qualifier
9、@Configuration
<beans>,作用为:配置spring容器(应用上下文)10、@Configuration + @Bean
<bean>,作用为:注册bean对象11、@Configuration + @Component
注册Bean对象
12、@PropertySource
@PropertySource注解将properties配置文件中的值存储到Spring的 Environment中,例如代码:
@PropertySource(value = "classpath:storage.properties")
13、@RequestMapping
控制器指定可以处理哪些 URL 请求;
14、@PathVariable、
@RequestHeader、@CookieValue、
@RequestParam、@RequestBody、
@SessionAttributes, @ModelAttribute
15、@PostConstruct、@PreDestroy
分别为:初始化注解(用在方法上)、销毁注解(默认单例,启动就加载,用在方法上)
Spring 部分常用注解的更多相关文章
- Spring Boot常用注解总结
Spring Boot常用注解总结 @RestController和@RequestMapping注解 @RestController注解,它继承自@Controller注解.4.0之前的版本,Spr ...
- Spring MVC学习总结(2)——Spring MVC常用注解说明
使用Spring MVC的注解及其用法和其它相关知识来实现控制器功能. 02 之前在使用Struts2实现MVC的注解时,是借助struts2-convention这个插件,如今我们使 ...
- Spring学习总结(2)——Spring的常用注解
本文汇总了Spring的常用注解,以方便大家查询和使用,具体如下: 使用注解之前要开启自动扫描功能 其中base-package为需要扫描的包(含子包). ? 1 <context:compon ...
- Spring Boot 常用注解汇总
一.启动注解 @SpringBootApplication @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documen ...
- 接近8000字的Spring/SpringBoot常用注解总结!安排!
0.前言 大家好,我是 Guide 哥!这是我的 221 篇优质原创文章.如需转载,请在文首注明地址,蟹蟹! 本文已经收录进我的 75K Star 的 Java 开源项目 JavaGuide:http ...
- Spring/SpringBoot常用注解总结
转自:[Guide哥] 0.前言 可以毫不夸张地说,这篇文章介绍的 Spring/SpringBoot 常用注解基本已经涵盖你工作中遇到的大部分常用的场景.对于每一个注解我都说了具体用法,掌握搞懂,使 ...
- Spring MVC常用注解
cp by http://www.cnblogs.com/leskang/p/5445698.html 1.@Controller 在SpringMVC 中,控制器Controller 负责处理由Di ...
- Spring Ioc 常用注解
在开发中spring ioc的配置方式有多种方式,常用的一般都是byName.byType .以及其自动装配可以查看http://www.cnblogs.com/gubai/p/9140840.htm ...
- spring 、spring boot 常用注解
@Profile 1.用户配置文件注解. 2.使用范围: @Configration 和 @Component 注解的类及其方法, 其中包括继承了 @Component 的注解: @Service. ...
- Spring 中常用注解原理剖析
前言 Spring 框架核心组件之一是 IOC,IOC 则管理 Bean 的创建和 Bean 之间的依赖注入,对于 Bean 的创建可以通过在 XML 里面使用 <bean/> 标签来配置 ...
随机推荐
- XCode10 运行app报错
原因很简单:Xcode10起,苹果摒弃了对libstdc++库的支持转而支持libc++库了.为了保证老代码能跑,必须将几个库复制到对应文件夹(见后).同时修改Build Phases中的Link B ...
- 【QT】文件读写操作
读取输出: QFile file("D:/Englishpath/QTprojects/1.dat"); if(!file.open(QIODevice::ReadOnly)) { ...
- nginx 内置变量
http://blog.sina.com.cn/s/articlelist_1834459124_1_1.html nginx内置变量杂谈 http://nginx.org/en/docs/http ...
- 转:SQL Server 动态行转列
http://www.cnblogs.com/gaizai/p/3753296.html http://www.cnblogs.com/maanshancss/archive/2013/03/13/2 ...
- 【Postgres】空间数据库创建
1.数据库创建问题-Navicat-ERROR: source database "template1" is being accessed by other users 2.解决 ...
- scala 隐式详解(implicit关键字)
掌握implicit的用法是阅读spark源码的基础,也是学习scala其它的开源框架的关键,implicit 可分为: 隐式参数 隐式转换类型 隐式调用函数 1.隐式参数 当我们在定义方法时,可以把 ...
- Spring Boot Starter 的基本封装
1)spring-boot-starter这是Spring Boot的核心启动器,包含了自动配置.日志和YAML. 2)spring-boot-starter-amqp通过spring-rabbit来 ...
- 删除或修改本地Git保存的账号密码
win10 系统下进入 控制面板 > 用户帐户 > 管理你的凭据 选择 [Windows 凭据] git 保存的用户信息在普通凭据列表里 >>编辑>>>完成
- ubuntu git的安装更新及配置
安装及配置 参考地址:http://blog.csdn.net/qq_26990831/article/details/51857399 1.git 安装 sudo apt-get install g ...
- react纯手写全选与取消全选
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...