码迷,mamicode.com
首页 > 编程语言 > 详细

spring入门概念

时间:2017-08-10 18:06:57      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:spring 概念 入门

spring是一个轻量级的IOC和AOP的容器框架,它主要是为了解决企业应用开发的复杂性而诞生的。目的是解决企业应用开发的复杂性。


spring的优点:

低入侵式设计,代码污染极低

write once run anywhere

di有效的降低了耦合度

aop提供了通用任务的集中管理

orm和dao简化了对数据库的访问

高度的开放性,并不强制


IOC:由spring控制对象的生命周期和依赖关系。

DI:依赖注入,ioc期间对象被动态的将依赖关系注入到对象中。

IOC和DI是不同方式描述同一件事情。


AOP

AOP代理其实是由AOP框架动态生成的一个对象,该对象可作为目标对象使用。

spring.xml标签
beans元素:根节点,beans中定义的全局属性,在bean元素中可以覆盖beans的属性。
属性:default-lazy-init是否延时加载,默认false
    default-dependency-check是否进行依赖关系检查
    default-autowire是否自动注入,默认no   none/byName/byType/constructor/autodetect
元素:description描述
    import引入其他的配置文件
    bean元素

bean元素:
属性:
    id
    name
    class
    parent 和class相同,不仅能使用class类中的属性,还能重写
    abstract
    scope
    lazy-init
    autowire
    dependency-check
    depends-on
    init-method
    destroy-method
    factory-method
    factory-bean

元素:
    description
    constructor-arg
    property
    lookup-method
    replace-method

constructor-arg元素:
    属性:index
        type
    元素:
        description
        bean
        ref
        idref
        list
        set
        map
        props-prop-key
        value
        null      

property元素:
    属性:
        name
    元素:
        description
        bean
        ref
        idref
        list
        set
        map
        props-prop-key
        value
        null


spring入门概念

标签:spring 概念 入门

原文地址:http://13172906.blog.51cto.com/13162906/1955193

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!