zoukankan      html  css  js  c++  java
  • 第一讲work(axe)

    1,Dao

    package com.songyan.Dao;
    
    public interface Axe {
    public void chop();
    }
    package com.songyan.Dao;
    
    public class StoneAxe implements Axe{
        public void chop() {
            System.out.println("axe~~~~");
        }
    
    }

    2,service

    package com.songyan.Dao;
    
    public class Chinese implements Person{
        private Axe axe;
        
        public Axe getAxe() {
            return axe;
        }
    
        public void setAxe(Axe axe) {
            this.axe = axe;
        }
    
        public void useAxe() {
            axe.chop();
            System.out.println("chinese~~~");
        }
    
    }
    package com.songyan.Dao;
    
    public interface Person {
    public void useAxe();
    }

    3,配置

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans.xsd">
        <bean id="chinese" class="com.songyan.Dao.Chinese">
            <property name="axe" ref="axe"></property>
        </bean>
        <bean id="axe" class="com.songyan.Dao.StoneAxe"></bean>
    </beans>

    4,测试

    package com.songyan.Dao;
    
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    public class Test {
        public static void main(String[] args) {
            ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
                    "com/songyan/Dao/ApplicationContext.xml");
            Chinese chinese = (Chinese) applicationContext.getBean("chinese");
            chinese.useAxe();
        }
    }
  • 相关阅读:
    Qt 交换Layout中的QWidget控件位置
    霍夫变换(Hough)
    图像傅里叶变换
    通俗讲解:图像傅里叶变换
    傅里叶分析之掐死教程(完整版)
    一幅图弄清DFT与DTFT,DFS的关系
    Qt 实现简单的TCP通信
    Qt 基于TCP的Socket编程
    Socket原理讲解
    科研相机选择:sCMOS还是CCD?
  • 原文地址:https://www.cnblogs.com/excellencesy/p/9110790.html
Copyright © 2011-2022 走看看