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="">

  • 相关阅读:
    黑白棋_lduoj_dfs深搜
    lduoj_2021年初寒假训练第41场
    Git学习day02
    Git学习day01
    python学习之urllib的使用
    SQL语句之授权与收回
    PHP学习之有问题找谁
    PHP学习之没有权限修改hosts文件
    PHP学习之创建本地站点
    python学习之常见错误
  • 原文地址:https://www.cnblogs.com/hylinux/p/6027236.html
Copyright © 2011-2022 走看看