(1) 、<context:component-scan base-package="*.*" />
 该配置隐式注册了多个对注解进行解析的处理器,如:
 AutowiredAnnotationBeanPostProcessor      
 CommonAnnotationBeanPostProcessor 
 PersistenceAnnotationBeanPostProcessor    
 RequiredAnnotationBeanPostProcessor 
 其实,注解本身做不了任何事情,和XML一样,只起到配置的作用,主要在于背后强大的处理器 
 其中就包括了<context:annotation-config/>配置项里面的注解所使用的处理器 
 所以配置了<context:component-scan base-package="">之后,便无需再配置<context:annotation-config>

(2)、@Component、@Repository、@Service、@Controller、@Autowired、@Resource
 而Spring2.5就为我们引入了组件自动扫描机制 
 它可以在classpath下寻找标注了@Service、@Repository、@Controller、@Component注解的类 
 并把这些类纳入Spring容器中管理,它的作用和在XML中使用bean节点配置组件是一样的 
 使用自动扫描机制,则需配置<context:component-scan base-package="com.jadyer"/>启动自动扫描 
 其中base-package指定需要扫描的包,它会扫描指定包中的类和子包里面类 
 @Service用于标注业务层组件 
 @Repository用于标注数据访问组件,即DAO组件 
 @Controller用于标注控制层组件,如Struts中的Action 
 @Component泛指组件,当组件不要好归类时,可以使用这个注解进行标注
 1、可以使用诸如@Service("personDao")修改bean名称,而它默认的是将首字母小写的类名作为<bean>名称 
 2、若要更改<bean>作用域的话,可以使用@Scope("prototype")注解来修改<bean>作用域

一般使用@Resource注解,而不要使用@Autowired注解 
 因为@Autowired注解是Spring提供的,而@Resource注解是J2EE提供的 
 在JDK6中就已经包含@Resource注解了,所以它没有跟Spring紧密耦合

(3)、<tx:annotation-driven />
 @Transactional 注解可以被应用于接口定义和接口方法、类定义和类的 public 方法上。
 Spring团队的建议是你在具体的类(或类的方法)上使用 @Transactional 注解,而不要使用在类所要实现的任何接口上。
 @Service
 @Transactional(rollbackFor=Exception.class)   //对当前类的所有方法起作用
 @SuppressWarnings("serial")
 public class ButtonBo extends GlobalBo {
  ....
  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true) //具体方法上
    public Button findButton(String buttonid) throws BaseException {
     return hibernateEntityDao.get(Button.class, buttonid);
   }
 }

 转载地址;http://blog.csdn.net/cdl2008sky/article/details/6265742,感谢作者分享

【转】Spring Annotation 详解的更多相关文章

  1. spring事务详解(四)测试验证

    系列目录 spring事务详解(一)初探事务 spring事务详解(二)简单样例 spring事务详解(三)源码详解 spring事务详解(四)测试验证 spring事务详解(五)总结提高 一.引子 ...

  2. spring事务详解(一)初探事务

    系列目录 spring事务详解(一)初探事务 spring事务详解(二)简单样例 spring事务详解(三)源码详解 spring事务详解(四)测试验证 spring事务详解(五)总结提高 引子 很多 ...

  3. [转载]Spring配置文件详解一:

    原文地址:与base-package="com.xx">Spring配置文件详解一:<context:annotation-config/>与<contex ...

  4. Java Annotation详解(二): 反射和Annotation

    前面一篇文<Java Annotation详解(一): 理解和使用Annotation>中,我们或许会觉得,Annotation注释其实并没有多大的作用,除了几个内建的Annotation ...

  5. Spring Aop 详解二

    这是Spring Aop的第二篇,案例代码很详解,可以查看https://gitee.com/haimama/java-study/tree/master/spring-aop-demo. 阅读前,建 ...

  6. Spring配置文件详解 – applicationContext.xml文件路径

    Spring配置文件详解 – applicationContext.xml文件路径 Java编程                 spring的配置文件applicationContext.xml的默 ...

  7. spring配置文件详解--真的蛮详细

    spring配置文件详解--真的蛮详细   转自: http://book.51cto.com/art/201004/193743.htm 此处详细的为我们讲解了spring2.5的实现原理,感觉非常 ...

  8. 【转载】Spring AOP详解 、 JDK动态代理、CGLib动态代理

    Spring AOP详解 . JDK动态代理.CGLib动态代理  原文地址:https://www.cnblogs.com/kukudelaomao/p/5897893.html AOP是Aspec ...

  9. J2EE进阶(四)Spring配置文件详解

    J2EE进阶(四)Spring配置文件详解 前言 Spring配置文件是用于指导Spring工厂进行Bean生产.依赖关系注入(装配)及Bean实例分发的"图纸".Java EE程 ...

随机推荐

  1. SPOJ - AMR11H

    Array Diversity Time Limit: 404MS   Memory Limit: 1572864KB   64bit IO Format: %lld & %llu Submi ...

  2. rest_framework 访问频率(节流)流程

    访问频率流程 访问频率流程与认证流程非常相似,只是后续操作稍有不同 当用发出请求时 首先执行dispatch函数,当执行当第二部时: #2.处理版本信息 处理认证信息 处理权限信息 对用户的访问频率进 ...

  3. (一)Centos7安装zabbix3.4 server端

    (1)环境准备 关闭firewalld和selinux systemctl stop firewalld systemctl disable firewalld #sed -ri '/^SELINUX ...

  4. magento 开启模板路径提示

    1.进入后台system->configuration->,选择main Website 2.advanced->developer中,将Debug中的Template Path H ...

  5. [解决] win7能上网,ubuntu14.04不行

    更新驱动 http://www.realtek.com.tw/downloads/downloadsView.aspx?Langid=1&PNid=13&PFid=5&Leve ...

  6. POJ 2367 Genealogical tree【拓扑排序/记录路径】

    Genealogical tree Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7101 Accepted: 4585 Spe ...

  7. 让你的mysql或mariadb 支持ipv6

    如果你在windows 或Linux系统已经安装了mysql/mariadb,并且操作系统本身已经支持了ipv6. 在/etc/my.conf 这样配置可以让mysql也支持ipv6 [mysqld] ...

  8. Codeforces #439 Div2 E

    #439 Div2 E 题意 给出二维平面,有多个询问: 把某一区域围起来(围墙之间无交点) 移除某一区域的围墙(此时保证围墙一定存在) 选定两个位置问是否可以互相到达 分析 看起来很复杂,其实这道题 ...

  9. CodeChef - UASEQ Chef and sequence

    Read problems statements in Mandarin Chinese and Russian. You are given an array that consists of n ...

  10. 【AC自动机/fail树】BZOJ3172- [Tjoi2013]单词

    [题目大意] http://www.lydsy.com:808/JudgeOnline/problem.php?id=3172 某人读论文,一篇论文是由许多单词组成.但他发现一个单词会在论文中出现很多 ...