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

3.黑白墨盒實現類BlackWhiteInk

4.彩色墨盒實現類ColorInk

5.紙張接口Paper

6. A4紙張實現類 A4Paper

7. B5紙張實現類B5Paper

8. 打印機類 Printer

9. 測試類PrintTest

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
【IntelliJ IDEA】Maven構建自己的第一個Java后臺的方法
本篇文章主要介紹了Maven構建自己的第一個Java后臺的方法,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-12-12
教你使用eclipse?搭建Swt?環(huán)境的全過程
本文給大家分享使用eclipse?搭建Swt?環(huán)境的全過程,本文通過圖文并茂的形式給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2021-12-12
微服務Redis-Session共享登錄狀態(tài)的過程詳解
這篇文章主要介紹了微服務Redis-Session共享登錄狀態(tài),本文采取Spring security做登錄校驗,用redis做session共享,實現單服務登錄可靠性,微服務之間調用的可靠性與通用性,需要的朋友可以參考下2023-12-12
Spring主配置文件(applicationContext.xml) 導入約束詳解
在本篇文章里我們給各位整理的是關于Spring主配置文件(applicationContext.xml) 導入約束的相關知識點內容,需要參考下。2019-08-08

