zoukankan      html  css  js  c++  java
  • 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>

  • 相关阅读:
    JAVA集合框架01
    java基础===>点餐系统
    java基础===>数组的应用
    java基础===>双重循环打印图形
    java基础 ===》循环结构
    JAVA基础==>witch的应用!
    选择结构!
    路由系统
    flask使用及返回值、配置文件的四种方式
    短信验证码操作
  • 原文地址:https://www.cnblogs.com/tk55/p/6498906.html
Copyright © 2011-2022 走看看