節錄重點:

@ 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. 关于概率算法的问题,不知道逻辑错在哪里,求debug

    做个骰子成功几率的分析,投n颗骰子,第一次投成功的几率是a,然后投成功的骰子,需要再投1次,这次成功的几率是b.第二次成功的骰子才算最终成功. 要分析出n颗骰子,最终成功0到n颗的概率. 我写了个算法 ...

  2. LINQ返回DataTable类型 list转dataset 转换为JSON对象

    using System.Web.Script.Serialization; using System.Collections.Generic; using System.Reflection; us ...

  3. 【Git 三】生成并添加SSH秘钥

    我们在 Windos 或 Linux 上克隆项目的时候, 如果走的是 http 会让输入 username 和 password,每次都要输入是很麻烦的. 为了省事儿.简单,我们可以选择 ssh 方式 ...

  4. python读取word文档

    周末需要做一个统计word文档字数的问题,刚开始以为很简单,因为之前做过excel表格相关的任务,所以认为利用扩展模块应该比较简单. 通过搜索,确实搜到了一个python操作word的模块,pytho ...

  5. spring-data-jpa 新增 修改 删除 查询 分页

      1.查询所有数据 findAll() 2.分页查询 findAll(new PageRequest(0, 2)) 3.根据id查询 findOne() 4.根据实体类属性查询: findByPro ...

  6. python 基础使用list、dict、set、可变与不可变对象

    参考链接:https://www.liaoxuefeng.com/wiki/1016959663602400/1017104324028448 dict是字典,可以储存键值对类型的值,set与dict ...

  7. 题解 CF915D 【Almost Acyclic Graph】

    这道题我第一次的想法是直接判环的数量,然而事实证明实在是太naive了. 随便画个图都可以卡掉我的解法.(不知道在想什么) 这道题的正解是拓扑排序. 朴素的想法是对所有边都跑一次拓扑,但这样$O(m( ...

  8. ArcGIS api for javascript——使用图层定义显示地图

    描述 本例展示如何使用图层定义来限制显示在地图上的图层信息.为了了解本例做了什么,看看用于这个地图的ESRI_Census_USA服务的服务目录页是有帮助的.检查地图中的图层列表.现在注意这行代码限制 ...

  9. java 自己定义异常,记录日志简单说明!留着以后真接复制

    log4j 相关配制说明:http://blog.csdn.net/liangrui1988/article/details/17435139 自己定义异常 package org.rui.Excep ...

  10. Android中集成ffmpeg(一):编译ffmpeg

    方案选择 Android中集成ffmpeg的codec功能无非两种方式: JNI直接调用,主要用于App开发(无权限修改系统底层),如EXOPlayer,JPlayer等. 集成ffmpeg到OMX, ...