欢迎来到代码驿站!

JAVA代码

当前位置:首页 > 软件编程 > JAVA代码

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

时间:2021-04-24 09:27:46|栏目:JAVA代码|点击:

这篇文章主要介绍了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

  

3.黑白墨盒实现类BlackWhiteInk

  

4.彩色墨盒实现类ColorInk

  

5.纸张接口Paper

  

6. A4纸张实现类 A4Paper

  

7. B5纸张实现类B5Paper

  

8. 打印机类 Printer

  

9. 测试类PrintTest

  

上一篇:Springboot+TCP监听服务器搭建过程图解

栏    目:JAVA代码

下一篇:struts2.3.24+spring4.1.6+hibernate4.3.11+mysql5.5.25开发环境搭建图文教程

本文标题:Spring案例打印机的实现过程详解

本文地址:http://www.codeinn.net/misctech/107773.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有