1、spring注解驱动开发 官方文档

  • @Configuration 告诉spring这是一个配置类,配置类=配置文件
  • @Bean 给容器中注入一个bean,类型为返回值类型,id默认用方法名作为id
@Bean
public Person person(){
       return new Person("Jack",22);
     }
  • 获取bean
ApplicationContext applicationContext = new  AnnotationConfigApplicationContext(MainConfig.class);
Person person = applicationContext.getBean(Person.class);
System.out.println("person:"+person);
  • 获取容器中bean数组:String[] names = applicationContext.getBeanDefinitionNames();
  • @ComponentScan(value = "com.hbut") 包扫描器,指定要扫描的包。配置在配置类上面。
  @ComponentScan(value = "com.hbut",excludeFilters = {@ComponentScan.Filter(type =FilterType.ANNOTATION,classes = {Controller.class, Service.class})})  //包扫描,按注解排除,排除Controller和service
  @ComponentScan(value = "com.hbut",includeFilters = {@ComponentScan.Filter(type =FilterType.ANNOTATION,classes = {Controller.class, Service.class})},useDefaultFilters =false) // 包扫描,只需要service和controller

Spring-framework的更多相关文章

  1. 浅谈对Spring Framework的认识

    Spring Framework,作为一个应用框架,官方的介绍如下: The Spring Framework provides a comprehensive programming and con ...

  2. Hello Spring Framework——依赖注入(DI)与控制翻转(IoC)

    又到年关了,还有几天就是春节.趁最后还有些时间,复习一下Spring的官方文档. 写在前面的话: Spring是我首次开始尝试通过官方文档来学习的框架(以前学习Struts和Hibernate都大多是 ...

  3. 手动创建Spring项目 Spring framework

    之前学习框架一直是看的视频教程,并且在都配套有项目源码,跟着视频敲代码总是很简单,现在想深入了解,自己从官网下载文件手动搭建,就遇到了很多问题记载如下. 首先熟悉一下spring的官方网站:http: ...

  4. 转-Spring Framework中的AOP之around通知

    Spring Framework中的AOP之around通知 http://blog.csdn.net/xiaoliang_xie/article/details/7049183 标签: spring ...

  5. spring 官方下载地址(Spring Framework 3.2.x&Spring Framework 4.0.x)

    spring官方网站改版后,建议都是通过 Maven和Gradle下载,对不使用Maven和Gradle开发项目的,下载就非常麻烦,下给出Spring Framework jar官方直接下载路径: h ...

  6. Spring Framework------>version4.3.5.RELAESE----->Reference Documentation学习心得----->Spring Framework中的spring web MVC模块

    spring framework中的spring web MVC模块 1.概述 spring web mvc是spring框架中的一个模块 spring web mvc实现了web的MVC架构模式,可 ...

  7. Spring Framework------>version4.3.5.RELAESE----->Reference Documentation学习心得----->Spring Framework中web相关的知识(概述)

    Spring Framework中web相关的知识 1.概述: 参考资料:官网documentation中第22小节内容 关于spring web mvc:  spring framework中拥有自 ...

  8. Spring Framework------>version4.3.5.RELAESE----->Reference Documentation学习心得----->关于spring framework中的beans

    Spring framework中的beans 1.概述 bean其实就是各个类实例化后的对象,即objects spring framework的IOC容器所管理的基本单元就是bean spring ...

  9. Spring Framework------>version4.3.5.RELAESE----->Reference Documentation学习心得----->使用spring framework的IoC容器功能----->方法一:使用XML文件定义beans之间的依赖注入关系

    XML-based configuration metadata(使用XML文件定义beans之间的依赖注入关系) 第一部分 编程思路概述 step1,在XML文件中定义各个bean之间的依赖关系. ...

  10. Spring Framework------>version4.3.5.RELAESE----->Reference Documentation学习心得----->使用Spring Framework开发自己的应用程序

    1.直接基于spring framework开发自己的应用程序: 1.1参考资料: Spring官网spring-framework.4.3.5.RELAESE的Reference Documenta ...

随机推荐

  1. Secret Message ---- (Trie树应用)

    Secret Message   总时间限制:  2000ms  内存限制:  32768kB 描述 Bessie is leading the cows in an attempt to escap ...

  2. You are what you write——沈向洋

    title: You are what you write--沈向洋 date: 2018-02-21 13:18:28 tags: [随想,write] categories: 个人文章 --- A ...

  3. Html和Css学习笔记-css进阶-盒模型

    我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! 此篇博客是我的复习笔记,html和css学的时间太久了,忘得差不多了,最近要使用一下,所以重新打开html的书略读,后记录了标签 ...

  4. max-width和width的区别

    width为宽度 max-width为最大宽度 如果设置了width,那宽度就定死了,不能动态的改变,显得僵硬 而设置了max-width,实际宽度可以在0~max-width之间,当元素内部宽度不足 ...

  5. Bootstrap中内联单选按钮

    <div class="form-group"> <label class="control-label">性别:</label& ...

  6. Monkey测试记录

    配置环境变量,不然用不了adb命令 path这里也一样配置一下 命令的各种意思百度一下看看也就知道了 看到一篇博客推荐的一种测试命令,我也直接拿来用了 adb shell monkey -p 你的包名 ...

  7. 数据库之redis篇(1)—— redis数据库安装,简单使用

    简介 reids,由Salvatore Sanfilippo写的一个高性能的key-value数据库,并且它是非关系型数据库,也就是没有像mysql那样多表链接操作,并且它是是完全开源免费的,遵守BS ...

  8. LNMP构建动态网站WordPress

    LNMP构建动态网站wordpress 一.部署LNMP架构 1.安装nginx #配置nginx源 cat>/etc/yum.repos.d/nginx.repo<<-EOF [N ...

  9. 超哥笔记 --nginx入门(6)

    一 NGINX 1 nignx是什么 nginx是一个开源的支持高性能,高并发的web服务和代理服务软件. nginx比他大哥apache性能改进许多,nginx占用的系统资源更少,支持高并发连接,有 ...

  10. webpack开发环境和生产环境切换原理

    在package.json中有如下设置: "scripts": {    "dev": "node build/dev-server.js" ...