zoukankan      html  css  js  c++  java
  • Spring中的Bean --- xml版

    这里先介绍下标签的基本含义

      bean-定义一个Bean实例的信息 通俗的讲就是一个对象 

        bean属性:

          id       指定生成的Bean实例名称

          name     指定生成的Bean实例名称

          scope    设定Bean实例的生成方式  默认是singleton模式 还有prototype多例模式 request、session、global session模式

          init-method  初始化时调用的方法 比如对象中含有a方法,可以配置此属性这样每次生成对象时都会调用a方法    

          destroy-method  属性实例销毁时要调用的方法   同init-method 但是需要scope设置成singleton模式

        bean子标签

          property   官方的话术是用来配置Bean实例的依赖关系(set方式注入,属性一定要有set方法),通俗讲就是配置对象属性的值

          constructor-arg   用来配置Bean实例的依赖关系(构造方式注入)

          ref      constructor-arg、property、list、set、entry等标记的子标记,指定一个Bean实例

          value     constructor-arg、property、list、set、entry等标记的子标记,指定一个常量

          list   用以封装List或数组类型属性的依赖注入  具体的元素通过refvalue子标记指定

          set       封装Set类型属性的依赖注入     具体的元素通过refvalue子标记指定

          map     封装Map类型属性的依赖注入    应为map是键值对,需要用entry子标签设置“键/值”对

      以上来自:https://www.cnblogs.com/ysmdbk/p/11398482.html

  • 相关阅读:
    Leetcode: K-th Smallest in Lexicographical Order
    Leetcode: Minimum Number of Arrows to Burst Balloons
    Leetcode: Minimum Moves to Equal Array Elements
    Leetcode: Number of Boomerangs
    Leetcode: Arranging Coins
    Leetcode: Path Sum III
    Leetcode: All O`one Data Structure
    Leetcode: Find Right Interval
    Leetcode: Non-overlapping Intervals
    Socket网络编程--简单Web服务器(3)
  • 原文地址:https://www.cnblogs.com/yishilin/p/12029572.html
Copyright © 2011-2022 走看看