软件编程
位置:首页>> 软件编程>> java编程>> Spring案例打印机的实现过程详解

Spring案例打印机的实现过程详解

作者:关耳er  发布时间:2023-12-02 12:28:47 

标签:spring,案例,打印机

这篇文章主要介绍了Spring案例打印机的实现过程详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

目录:

Spring案例打印机的实现过程详解

1.applicationContext.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"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans.xsd">
 <!--注入bean
   id相当于当前bean唯一标识
   class是bean 的全路径
   property注入bean中的属性     必须封装
 -->
 <!--注入墨盒-->
 <bean id="colorInk" class="cn.spring.print.ink.ColorInk"></bean>
 <bean id="blackWhiteInk" class="cn.spring.print.ink.BlackWhiteInk"></bean>
 <!--注入纸张-->
 <bean id="a4Paper" class="cn.spring.print.paper.A4Paper"></bean>
 <bean id="b5Paper" class="cn.spring.print.paper.B5Paper"></bean>
 <!--打印机-->
 <bean id="printer" class="cn.spring.print.printer.Printer">
   <!--将墨盒纸张组合起来-->
   <property name="paper" ref="b5Paper"></property>
   <property name="ink" ref="colorInk"></property>
 </bean>
</beans>

2.墨盒接口Ink

Spring案例打印机的实现过程详解

3.黑白墨盒实现类BlackWhiteInk

Spring案例打印机的实现过程详解

4.彩色墨盒实现类ColorInk

Spring案例打印机的实现过程详解

5.纸张接口Paper

Spring案例打印机的实现过程详解

6. A4纸张实现类 A4Paper

Spring案例打印机的实现过程详解

7. B5纸张实现类B5Paper

Spring案例打印机的实现过程详解

8. 打印机类 Printer

Spring案例打印机的实现过程详解

9. 测试类PrintTest

Spring案例打印机的实现过程详解

来源:https://www.cnblogs.com/Zzzzn/p/11731519.html

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com