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

  • 相关阅读:
    弹性盒模型的实际应用
    大图滚动--这是精髓实例
    三级联动
    sql
    jsp2
    marquee
    人机五子棋(AI算法有瑕疵)
    Jsp1
    倒计时
    时间
  • 原文地址:https://www.cnblogs.com/hylinux/p/6027236.html
Copyright © 2011-2022 走看看