`

Why Spring

阅读更多
IOC(Inverse of Control)/DI(Dependency Inverse): 控制反转与依赖注入.
由容器来管理对象之前的依赖关系,而不是对象本身来管理,就叫控制反转.
IOC 是一种思想.Spring的基本思想就是IOC/DI.
Spring 就是一个IOC容器.
解决了工厂泛滥的问题.

[list]
  • Spring 依赖包:
  •      Spring_HOME\dist\spring.jar
         Spring_HOME\lib\jakarta-commons\commons-logging.jar
         Spring_HOME\lib\log4j\log4j-1.2.15.jar
  • Copy spring's configuration file to project src folder.
  • 在相应的类中提供set方法,并在Spring的配置文件中配置一下,让spring提供对象.
  •    也可能通过构造器进行注入.
       关键点:applicationContext.xml Spring配置文件.
  • applicationContext.xml
  • <?xml version="1.0" encoding="UTF-8"?>
    
    <!--
      - Application context definition for JPetStore's business layer.
      - Contains bean references to the transaction manager and to the DAOs in
      - dataAccessContext-local/jta.xml (see web.xml's "contextConfigLocation").
      -->
    <beans xmlns="http://www.springframework.org/schema/beans"
    		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    		xmlns:aop="http://www.springframework.org/schema/aop"
    		xmlns:tx="http://www.springframework.org/schema/tx"
    		xsi:schemaLocation="
    			http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    			http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    			http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
    	<bean id="userDao4Mysql" class="com.cnet.spring.dao.UserDao4Mysql"></bean>
    	
    	<bean  id="userDao4Oracle" class="com.cnet.spring.dao.UserDao4Oracle"></bean>
    	
    	<bean id="userManager" class="com.cnet.spring.manager.UserManager">
    		<property name="userDao" ref="userDao4Mysql"/>
    	</bean>
    	
    </beans>
    

    [/list]
    分享到:
    评论

    相关推荐

      1.spring_whyspring

      NULL 博文链接:https://taoistwar.iteye.com/blog/251391

      Spring学习笔记之一“why spring”

      NULL 博文链接:https://whp0731.iteye.com/blog/355966

      spring示例代码好又全.rar

      内容如下: spring.rar [spring_aop1] ...injection1] [spring_injection2] [spring_scope] [spring_struts_1] [spring_struts_2] [spring_struts_hibernate] [spring_whyspring] [ssh_training_itemmgr]

      Why use with Struts + Spring + Hibernate

      Why use with Struts + Spring + Hibernate

      Spring Core And AOP

      this is doc include : Introduction Why Spring ? Spring IOC Spring AOP Spring vs EJB

      spring ppt

      Why Spring? How to learn Spring

      微服务系列第七十一季-Spring入门

      1-Why Spring 2-What can Spring do 3、What You Will Build 4、What You Need 5、How to complete this guide 6、Starting with Spring Initialize 7、Create a Resource Representation Class 8、Create a ...

      Pro Spring 3

      Aspect-oriented programming techniques with Spring, and why they’re important Data access and persistence using Spring and Hibernate, MyBatis, JPA 2 and more How to build transaction engines for your...

      Mastering.Spring.Cloud

      Why subscribe? PacktPub.com Contributors About the author About the reviewer Packt is searching for authors like you Preface Who this book is for What this book covers To get the most out of this book...

      spring.microservices.in.action

      Chapter 1 introduces you to why the microservices architecture is an important and relevant approach to building applications, especially cloud-based applications. Chapter 2 walks you through how to ...

      spring经典文档pdf

      spring学习最好的pdf,可以学到很深入的spring的框架知识

      pro spring batch

      How to implement a robust, scalable, distributed batch processing system using open-source frameworks Pro Spring Batch gives concrete examples of how each piece of functionality is used and why it ...

      thymeleaf-extras-springsecurity-3.0-master.zip

      Remember that Spring Security sets a special security-oriented object as expression root, which is why you would not be able to access the expectedRole variable directly in the above expression. ...

      spring-boot-reference-guide-zh_cn

      如果你想从大体上了解Spring Boot或Spring,本章节正是你所需要的!..."和"why?"等问题,并通过一些安装指南简单介绍 下Spring Boot。然后我们会构建第一个Spring Boot应用,并讨论一些需要遵循的 核心原则

      Wrox.Professional.Java.Development.with.the.Spring.Framework.pdf

      Written by the lead developers of the Spring Framework,...spring can do but why, explaining its functionality and motivation to help you use all parts of the framework to develop successful applications.

      spring-framework-reference-4.1.2

      3. New Features and Enhancements in Spring Framework 4.0 ............................................ 17 3.1. Improved Getting Started Experience .........................................................

      Learning Spring 5.0

      Get to know the basics of Spring development and gain fundamental knowledge about why and where to use Spring Framework Explore the power of Beans using Dependency Injection, wiring, and Spring ...

      pro spring dm server

      I have been a big fan of the Spring Framework since its first release in 2004 and have been using it in almost all my projects. When the application server written by the same company—the ...

    Global site tag (gtag.js) - Google Analytics