<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc"  xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:util="http://www.springframework.org/schema/util"xmlns:jpa="http://www.springframework.org/schema/data/jpa"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsdhttp://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsdhttp://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsdhttp://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsdhttp://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsdhttp://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd"><!-- 将指定类dao.TestDaoImpl配置给spring,让spring创建其实例 --><bean id="test" class="dao.TestDaoImpl" /></beans>

测试类代码:(省去了接口和实现类)

package test;import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;import dao.ITestDao;public class Tests {@Testpublic void test1() {//初始化spring容器ApplicationContext,加载配置文件ApplicationContext appCon = new ClassPathXmlApplicationContext("applicationContext.xml");//通过容器获取test实例ITestDao tt = (ITestDao) appCon.getBean("test");tt.sayHello();}
}

转载于:https://www.cnblogs.com/WaterGe/p/11267115.html

简单的Spring配置文件相关推荐

  1. 使用Dubbo实现简单的RPC调用(Spring配置文件版)

    更多文章和资源欢迎访问:SuperCoder Blog 文章目录 更多文章和资源欢迎访问:[SuperCoder Blog](https://supercoder.com.cn) 前言 一.Dubbo ...

  2. 转 spring配置文件

    spring配置文件 pom文件: <properties><commons-lang.version>2.6</commons-lang.version>< ...

  3. spring配置文件import标签中使用${}占位符获得配置文件的属性值

    2019独角兽企业重金招聘Python工程师标准>>> 一般情况下我们在Spring的配置文件中使用<import>标签是这样的,<import resource= ...

  4. 三大框架开发时,spring配置文件出现异常

    在最近利用三大框架进行项目开发时,spring配置文件里出现了一个橘***的双向箭头,鼠标放上去,会提示你advised by  org.springframework.transaction.int ...

  5. XML配置文件的命名空间与Spring配置文件中的头

    一直以来,写Spring配置文件,都是把其他配置文件的头拷贝过来,最多改改版本号,也不清楚哪些是需要的,到底是干嘛的.今天整理一下,拒绝再无脑copy. 一.Spring配置文件常见的配置头 < ...

  6. 【spring教程之中的一个】创建一个最简单的spring样例

    1.首先spring的主要思想,就是依赖注入.简单来说.就是不须要手动new对象,而这些对象由spring容器统一进行管理. 2.样例结构 如上图所看到的,採用的是mavenproject. 2.po ...

  7. spring配置xml文件_XML配置文件中的Spring配置文件

    spring配置xml文件 我的上一个博客非常简单,因为它涵盖了我从Spring 3.0.x到Spring 3.1.x的轻松升级,最后我提到可以将Spring模式升级到3.1,以利用Spring的最新 ...

  8. Spring配置文件和Java配置

    我的上一个博客介绍了Spring 3.1的配置文件,并解释了使用它们的业务案例,并演示了它们在Spring XML配置文件中的用法. 但是,似乎很多开发人员更喜欢使用Spring的基于Java的应用程 ...

  9. XML配置文件中的Spring配置文件

    我的上一个博客非常简单,因为它涵盖了我从Spring 3.0.x到Spring 3.1.x的轻松升级,最后我提到可以将Spring模式升级到3.1,以利用Spring的最新功能. 在今天的博客中,我将 ...

  10. 《设计模式详解》手写简单的 Spring 框架

    自定义 Spring 框架 自定义 Spring 框架 Spring 使用回顾 Spring 核心功能结构 bean 概述 Spring IOC 相关接口 BeanFactory 接口 BeanDef ...

最新文章

  1. c语言数据结构线性表LA和LB,数据结构(C语言版)设有线性表LA(3,5,8,110)和LB(2,6,8,9,11,15,20)求新集合?...
  2. 详细介绍Oracle DBA工作职责
  3. spring源码分析之spring-web web模块分析
  4. java for 迭代器_Java基础-迭代器Iterator与语法糖for-each
  5. matlab目标支持包安装问题,配置系统目标文件 - MATLAB Simulink - MathWorks 中国
  6. 如何获取组SPGroup的描述Description信息
  7. DWR学习笔记 - Hello World
  8. stm32定时器编码器模式原理及配置
  9. cJSON基本使用方法
  10. Activity的启动流程分析与总结
  11. cad修改快捷键_【收藏】史上最齐全的CAD大全
  12. Linux 查看网络流量 iftop
  13. 汇丰银行的华尔街恐怖故事
  14. 【NISP一级】3.2 防火墙
  15. 如何成为ffmpeg开发者
  16. 不得不知道的搜索引擎使用技巧(思维导图版)
  17. 转自知识号新闻网的一个帖子
  18. 杜克大学计算机统计学,杜克大学的统计学专业怎么样?
  19. 默克尔树特点及优缺点
  20. Python中计时,看这一篇就够了

热门文章

  1. 图解 Git,一目了然!
  2. 张一鸣念员工报告讽刺“互联网八股文” 网友:老板都看不惯了
  3. 厉害,Spring Boot 2.3.0 刚刚发布了!
  4. 百亿级日访问量的应用如何做缓存架构设计?
  5. 阿里Goldeneye业务监控平台之架构演进,如何实时处理100T+/天的日志量?
  6. 如何查看 Linux 服务器性能参数指标?
  7. Google 中国开发者大会最后一天报名!
  8. 数据结构时间复杂度_数据结构之时间复杂度分析
  9. Linux中级之netfilter/iptables应用及补充
  10. 【Shell 脚本】Mysql 定时备份