zoukankan      html  css  js  c++  java
  • 【Spring实战4】06---装配Bean(xml)

    通过XML装配Bean

    创建XML配置规范

    如下Spring XML配置所示:

    <?xml version="1.0" encoding="UTF-8"?>
    <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"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-xsd">
            <bean id="car" class="nh.spring.ioc.beans.Car">
                <property name="brand" value="Ca11"/>
                <property name="color" value="blue"/>
            </bean>
    
            <bean id="runCar" class="nh.spring.ioc.beans.RunCar">
                <constructor-arg value="#{T(System).out}"/>
            </bean>
    
            <aop:config>
                <aop:aspect ref="runCar">
                    <aop:pointcut id="show" expression="execution(* show())"/>
                    <aop:before method="carBeforeRun" pointcut-ref="show"/>
                    <aop:after method="carAfterRun" pointcut-ref="show"/>
                </aop:aspect>
            </aop:config>
    </beans>

    在使用XML时,需要在配置文件的声明多个xml模式xsd,定义配置spring的xml元素

    bean都包含在 <beans>元素中

    构造器注入

    <constructor-arg ref="">

  • 相关阅读:
    【Python教程】3道循环结构练习题
    python3中实现print不换行的方法
    零基础学Python:字典(Dictionary)详细教程
    TS错误提示
    v-slot的简单理解应用
    Typora使用方法简单整理
    Java基础系列(6)- 面向对象(中)
    monkey基础 (7)
    monkey基础 (6)
    monkey基础 (5)
  • 原文地址:https://www.cnblogs.com/hylinux/p/6027236.html
Copyright © 2011-2022 走看看