• spring4笔记----spring4构造注入


    与设值注入有以下不同,颜色标出

    package com.ij34.web;
    import com.ij34.servce.people;
    import com.ij34.servce.root;
    
    public class chinese implements people{
        private root dog;
    
    
        public root getDog() {
            return dog;
        }
    
    
    /*    public void setDog(root dog) {
            this.dog = dog;
        }*/
        public chinese(root dog) {
            this.dog = dog;
        }
        @Override
        public void cut() {
            // TODO Auto-generated method stub
            System.out.println("我是中国人");
            System.out.println(dog.chop());
        }
        
        
    }

    <?xml version="1.0" encoding="GBK"?>
    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://www.springframework.org/schema/beans"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-4.3.xsd">
    
     <bean id="chinese" class="com.ij34.web.chinese">
    <!--  <property name="dog" ref="iron"></property>
     -->
     <constructor-arg ref="iron" type="com.ij34.servce.root"></constructor-arg>
      </bean>
     <bean id="stone" class="com.ij34.web.stonechop"></bean>
     <bean id="iron" class="com.ij34.web.ironchop"></bean>
    </beans>

  • 相关阅读:
    div定位左右居中
    highcharts绘制3D倾斜的饼图
    Echarts 图表不能渲染问题整理
    RK:系统手势监听
    RK:网络共存、Shell脚本
    泛型
    ArrayList类
    Linux(centos7)安装ClickHouse
    centos安装宝塔命令
    centos下修改hosts文件以及生效命令
  • 原文地址:https://www.cnblogs.com/tk55/p/6498906.html
Copyright © 2020-2023  润新知