spring Bean的作用域:

      

scope可以取值: 

       * singleton:每次调用getBean的时候返回相同的实例

       * prototype:每次调用getBean的时候返回不同的实例

 

根据名称自动装配

<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.0.xsd

           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd

           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"

           default-autowire="byName"

           >

不适合实施阶段

 

根据类型自动装配

<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.0.xsd

           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd

           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"

           default-autowire="byType"

           >

相关文章:

  • 2021-11-14
  • 2021-07-08
  • 2021-09-10
  • 2021-08-16
  • 2021-08-15
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
猜你喜欢
  • 2021-08-17
  • 2021-04-01
  • 2021-04-06
  • 2022-01-18
  • 2021-08-04
  • 2021-05-01
  • 2022-12-23
相关资源
相似解决方案