IOC:inversion of Control  控制反转,Spring框架的核心。削减计算机程序的耦合问题,把对象(例如JDBC)的创建权交给Spring。

IOC的两种类型:

  • 依赖注入:
  • 依赖查找:

Spring安装包下载地址:http://repo.spring.io/libs-release-local/org/springframework/spring/

 解压Spring安装包:

  • docs:Spring的开发规范、API
  • libs:Spring的开发jar包、源码
  • schema:Spring的配置文件的约束

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAnoAAACXCAYAAACC7/Z5AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAACb3SURBVHhe7Z3Nkxy3eYf3nn/Af0AOOaR8cQ6pvaQqiU0nouPyKb4mhzm4opvvtkiRS4qUPREtUiRFskmJvPkSp7ayVblINmM5oSWvXWSlak+q8GO0VELJH+QulxSC9wXQDaBfoBvD3Zmd3t9ThZqd7sbbAKa78Sy6Z7CkAAAg4t69e/YvMETw+Q4bfL4vxtDaD6IHAAAAADBQIHoAAAAAAAMFogcAAAAAMFAgegAAAAAAAwWiBwAAAAAwUCB6AAAAAAADBaIHAAAAADBQIHoAAAAAAAOlSPR+u/4N9fmvDqvPPzqsPqP04WH16JcvmXTrJfV///W3nP73P/9Wffbr79hcAAAAAABgHhSJHkmeeviOTtd0qpTavKLTJZ3eVuqTCzqdV2pyTqez6tNf/I3NBQAAAAAA5kGZ6H1EotcteWryI/XpBxA9AAAAAIB5UiR6dLu2j+SpB2+oh6WitzpSS8tjtWHfAgAA2A9M1NrKy6pat29TrFdqZW1i31j0spc7M+o9rK10xwcATEWZ6H2oRa+H5KkH/6we/vzrNldPIHoALA7Ugb/8sk0rKuzf11WVXEeY9bEUUGffxNRJ6vkna2rl5UpHcMix8uWz9IjVKpNNaSnpqrshW1cuV3eM2UL1ypdlvWrW139D9ACYO0WiR1+66CN56sEP1eZ/QPQAGCa6019ZU3Wfz1LlhMmM/tSyJKyj91XVlrN1YVkMCYHZJhcrV76GfrEiWnLok6t7SLquRhRr6a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A2BaikSPpjXjeW57pO8fOWpzgRRdokdMJpuQPXCAof/Qd+uZmt2MBQAAi0GR6NG0ZjTjBf0YMv1OHv2ECn27lr54Qc/k0e1aGskjyfveK0dsLpCij+gRH3/8Pyx7AAAAAAAlFIke2F1i0fv975/Yv8yXMeIEAAAAAFACRG+O+KJHkvdHf/Ql9ZN//Xd+/1d//XfqX37yb/w3AAAAAMA0QPTmiBM9J3n0HN6f/umf8zK6Xev+BgAAAACYBojeHCHR8yWPeOnw36v33/9F/TdG9QAAAAAwLRC9OULP3fmSR9Dff/Inf8Z/37nz3+rLX17mvwEAAAAASoHo7UNoJI8kj/jKV/6CXwEAAAAASoHo7UPu3XvAo3r/8I//pD788Nd2KQAAAABAGRA9AAAAAICBAtEDAAAAABgoED0AAAAAgIEC0QMAAAAAGCgQPQAAAACAgQLRAwAAAAAYKBA9AAAAAICBAtEDAAAAABgoED0AAAAAgIEC0QMAAAAAGCgQPQAAAACAgQLRAwAAAAAYKBA9AAAAAICBAtEDAAAAABgkSv0/I/mjJNpCCBAAAAAASUVORK5CYII=" alt="" />

创建web项目,引入IOC所需jar包

编写类和接口

 问题:能不能在不修改源代码的前提下,将DAO的实现由JDBC切换到HIbernate?

Spring的IOC底层实现:

原来的方法:用工厂模式取代面向接口,降低了接口与实现类之间的耦合。原来改很多类,现在改一个工厂类,但是依然和工厂之间有耦合。

解决方案:工厂+反射 + 配置文件实现解耦合,通过解析xml与反射,生成实例。改动只需要修改配置文件即可。

 Spring的方式:

将接口和实现类交给Spring管理:

创建配置文件:applicationContext.xml

约束所在文件位置:Spring/spring-framework-4.2.4.RELEASE/docs/spring-framework-reference/html/xsd-configuration.html

 <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- Spring的入门配置 -->
<bean id="UserDao" class="com.itheima.spring.demo1.UserDaoImpl"></bean> </beans>

编写测试类:

如果要更改底层实现,只需改配置文件:

<bean id="UserDao" class="com.itheima.spring.demo1.UserDaoImpl"></bean>
-->
<bean id="UserDao" class="com.itheima.spring.demo1.UserDaoHibernateImpl"></bean>

结果:

二 Spring的IOC入门,环境搭建,Spring测试类的更多相关文章

  1. SSM(Spring+SpringMVC+Mybatis)框架环境搭建(整合步骤)(一)

    1. 前言 最近在写毕设过程中,重新梳理了一遍SSM框架,特此记录一下. 附上源码:https://gitee.com/niceyoo/jeenotes-ssm 2. 概述 在写代码之前我们先了解一下 ...

  2. 【转载】Maven+druid+MyBatis+Spring+Oracle+Dubbo开发环境搭建

    原地址:http://blog.csdn.net/wp1603710463/article/details/48247817#t16 Maven+druid+MyBatis+spring+Oracle ...

  3. 基于Maven的Spring + Spring MVC + Mybatis的环境搭建

    基于Maven的Spring + Spring MVC + Mybatis的环境搭建项目开发,先将环境先搭建起来.上次做了一个Spring + Spring MVC + Mybatis + Log4J ...

  4. 项目SpringMVC+Spring+Mybatis 整合环境搭建(2)-> 测试Spring+Mybatis 环境

    测试前期准备 第一步:创建easybuy数据库,设置utf-8格式 第二步:创建表test_tb CREATE TABLE `test_tb` ( `id` int(11) NOT NULL AUTO ...

  5. 死磕Spring之IoC篇 - 深入了解Spring IoC(面试题)

    该系列文章是本人在学习 Spring 的过程中总结下来的,里面涉及到相关源码,可能对读者不太友好,请结合我的源码注释 Spring 源码分析 GitHub 地址 进行阅读 Spring 版本:5.1. ...

  6. Windows C#入门环境搭建

    Windows C#入门环境搭建 1. 安装Microsoft .NET Framework目录: C:\Windows\Microsoft.NET\Framework,查看已经安装的版本. 如果未安 ...

  7. ArcGIS API for Silverlight/ 开发入门 环境搭建

    Silverlight/ 开发入门 环境搭建1 Silverlight SDK下载ArcGIS API for Microsoft Silverlight/WPF ,需要注册一个ESRI Gloab ...

  8. Android开发使用控件入门--环境搭建

    Android开发使用控件入门--环境搭建 软件名称(,梦,,想.CAD  ,控件) 1. 环境搭建: 3 1.1. 安装Eclipse 3 1.2. 下载JDK 3 1.3. 下载Android S ...

  9. 57.NodeJS入门--环境搭建 IntelliJ IDEA

    转自:https://blog.csdn.net/wang19891106/article/details/51127133 NodeJS入门–环境搭建 IntelliJ IDEA 本人也刚开始学习N ...

  10. NodeJS入门--环境搭建 IntelliJ IDEA

    NodeJS入门–环境搭建 IntelliJ IDEA 本人也刚开始学习NodeJS,所以以此做个笔记,欢迎大家提出意见. 1.首先 下载安装NodeJS,下载安装IntelliJ IDEA 2.接下 ...

随机推荐

  1. 数据库程序接口——JDBC——API解读第一篇——建立连接的核心对象

    结构图 核心对象 Driver Java通过Driver接口表示驱动,每种类型的数据库通过实现Driver接口提供自己的Driver实现类. Driver由属性,操作,事件三部分组成. 属性 公共属性 ...

  2. samba文件共享及账户映射

    samba文件共享及账户映射 实验介绍:在虚拟机Linux系统上安装sanmba服务,并在另外一台虚拟机的win7系统上访问共享文件夹,主要分为:匿名访问.身份验证访问.以及添加白名单和为了保护服务器 ...

  3. org.apache.catalina.connector.ClientAbortException: java.io.IOException: 你的主机中的软件中止了一个已建立的连接。

    org.apache.catalina.connector.ClientAbortException: java.io.IOException: 你的主机中的软件中止了一个已建立的连接. at org ...

  4. 粪发涂墙-tomcat

    tomcat 的 JAVA_OPTS 分析设置 快乐生活你我 2019-08-12 06:07:00 JAVA_OPTS ,顾名思义,是用来设置JVM相关运行参数的变量. 1.JVM:JAVA_OPT ...

  5. oracle 12cR2 RAC deconfig CRS过程记录

    已经停了该节点的crs所有服务: [root@jhjzksrv02 install]# ./rootcrs.sh -force -deconfig -verboseUsing configuratio ...

  6. Java 中 CAS

    一.CAS 概念 CAS ,全称 Compare And Swap(比较与交换),解决多线程并行情况下使用锁造成性能损耗的一种机制. 实现思想 CAS(V.A.B) ,V为内存地址,A为预期原值,B ...

  7. Linux上FTP部署:基于mariadb管理虚拟用户

    FTP原理 FTP 采用 Internet 标准文件传输协议 FTP 的用户界面, 向用户提供了一组用来管理计算机之间文件传输的应用程序.图1 FTP 的基本模型 FTP 是基于客户---服务器(C/ ...

  8. 【PAT甲级】1085 Perfect Sequence (25 分)

    题意: 输入两个正整数N和P(N<=1e5,P<=1e9),接着输入N个正整数.输出一组数的最大个数使得其中最大的数不超过最小的数P倍. trick: 测试点5会爆int,因为P太大了.. ...

  9. 【MySQL】外键的变种

    " 目录 三种关系 多对一 多对多 一对一 因为有foreign key的约束,使得两张表形成了三种关系: 多对一 多对多 一对多 重点理解如何找出两张表之间的关系 现在有A.B两张表 分析 ...

  10. IIS 部署 web service

    1.在控制台检查 IIS 功能是否已经全部启用 2.重新注册IIS 3.设定程序池的正确版本