節錄重點:

@ Resource 、@ PostConstruct、@ PreDestro、@PersistenceContext、@Required 都必須聲明相關的 bean

所以如果總是需要按照傳統的方式一條一條配置顯得有些繁瑣和沒有必要,於是spring給我們提供<context:annotation-config/>的簡化配置方式,自動幫你完成聲明。

但使用註解一般都會配置掃瞄包路徑選項

<context:component-scan base-package=」XX.XX」/>

該配置項其實也包含了自動注入上述processor的功能,因此當使用 <context:component-scan/> 後,就可以將 <context:annotation-config/> 移除了。

原文出處:

http://mushiqianmeng.blog.51cto.com/3970029/723880

英文:

How to use

http://howtodoinjava.com/spring/spring-core/how-to-use-spring-component-repository-service-and-controller-annotations/

Difference Between @Component, @Service, @Repository and @Controller:

http://javapapers.com/spring/spring-component-service-repository-controller-difference/

[ Java ] [ Spring ] Spring 一些配置项 及 <context:annotation-config/> 專文解释说明的更多相关文章

  1. 【Java】Spring之基于注释的容器配置(四)

    注释是否比配置Spring的XML更好? 基于注释的配置的引入引发了这种方法是否比XML“更好”的问题.答案是每种方法都有其优点和缺点,通常,由开发人员决定哪种策略更适合他们.由于它们的定义方式,注释 ...

  2. spring 2.5.6 错误:Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher

    在运行一个第三方公司交付的项目的时候, 出现: Caused by: java.lang.IllegalStateException: Context namespace element 'annot ...

  3. java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderL,spring获取context

    今天学习spring项目的时候出现了下面的错误信息: java.lang.ClassNotFoundException: org.springframework.web.context.Context ...

  4. Spring配置之context:annotation与、component-scan以及annotation-driven

    spring boot帮助我们隐藏了大量的细节,有些配置spring boot都是开启的,因此当我们查看遗留项目使用spring时候遇见问题一定细心排查 <!-- context:annotat ...

  5. maven创建spring项目之后,启动报错java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

    出错情景:maven中已经加载了spring的核心包,但是项目启动时,报错: org.apache.catalina.core.StandardContext listenerStart严重: Err ...

  6. spring异常 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet

    spring异常 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet   情况 ...

  7. java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener,环境Spring+Maven

    记录一下莫名出现的错误.Spring+Maven+STS. 严重: Error configuring application listener of class org.springframewor ...

  8. maven创建spring项目之后,启动报错java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoade

    错误: org.apache.catalina.core.StandardContext listenerStart严重: Error configuring application listener ...

  9. 在eclipse中运行spring web application时的异常: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

    严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderLis ...

随机推荐

  1. PostgreSQL Replication之第二章 理解PostgreSQL的事务日志(2)

    2.2 XLOG和复制 在本章中,您已经了解到PostgreSQL的事务日志已经对数据库做了所有的更改.事务日志本身被打包为易用的16MB段. 使用这种更改集来复制数据的想法是不牵强的.事实上,这是在 ...

  2. mac terminal终端怎么退出python命令行

    >>>使用 quit(), exit(), 或者Command+d,或者Command+z退出命令行.

  3. js循环匹配组合成新对象或js循环组合新数据

    var Arry=[ {name: "vehicleTravelLicenseCopyBack", id: "a1"}, {name: "vehicl ...

  4. 【Codeforces Round #422 (Div. 2) A】I'm bored with life

    [题目链接]:http://codeforces.com/contest/822/problem/A [题意] 让你求a!和b!的gcd min(a,b)<=12 [题解] 哪个小就输出那个数的 ...

  5. 二 MapReduce 各阶段流程分析

    如果想要将问题变得清晰.精准和优雅, 需要关注 MapReduce 作业所需要的系统资源,尤其是集群内部网络资源使用情况. MR 可以运行在共享集群上处理 TB 级 甚至 PB 级的数据.同时,改作业 ...

  6. DICOM:Transfer Syntax传输语义之奇葩GE Private TS

    背景: 专栏之前对Transfer Syntax(暂定中文翻译为传输语义,8月初博客中提到的DICOM3.0标准中文版开源书籍计划顺利启动.兴许会面临诸多专有名词的翻译工作,欢迎广大博友提意见)进行过 ...

  7. No WebApplicationContext found: no ContextLoaderListener registered?报错解决

    今天跑了下新搭的一个SSI框架. 报例如以下错误: 严重: Exception sending context initialized event to listener instance of cl ...

  8. JAVA类库LinkList的基本实现

    写完调试了好久,边界不优点理,具体的请看JDK类库,下面仅仅是基本实现: import java.util.Iterator; /** * 类名:MyLinkedList 说明:LinkedList的 ...

  9. html5的代码验证

    http://html5.validator.nu/ http://validator.w3.org/#validate_by_uri

  10. 网站及监控利器 Pandora FMS使用体验

    Pandora FMS 是一个 开源的应用程序 ,用来监测网站的各种活动,它可以收到实时的监测报告,并发送到你指定的邮箱,也可以通过e-mail, SMS 发送. 650) this.width=65 ...