精讲23种设计模式-策略模式~聚合短信服务和聚合支付服务
文章目錄
- 一、設(shè)計(jì)模式
- 1. 為什么需要使用設(shè)計(jì)模式
- 2. 設(shè)計(jì)模式的分類(lèi)
- 3. 什么是策略模式
- 4. 為什么叫做策略模式
- 5. 策略模式優(yōu)缺點(diǎn)
- 6. 策略模式應(yīng)用場(chǎng)景
- 7. Spring框架中使用的策略模式
- 二、策略模式~聚合短信服務(wù)
- 2.1. 依賴(lài)引入
- 2.2. 抽象公共行為接口
- 2.3. 具體策略接口實(shí)現(xiàn)類(lèi)
- 2.4. 策略枚舉
- 2.5. 獲取具體策略實(shí)現(xiàn)
- 2.6. 策略工廠
- 2.7. 聚合短信服務(wù)測(cè)試
- 三、聚合短信服務(wù)2
- 3.1. 策略工廠調(diào)整
- 3.2. 聚合短信測(cè)試
- 四、聚合短信3
- 4.1. 策略上下文
- 4.2. SpringContext上下文工具類(lèi)
- 4.3. 聚合短信測(cè)試
- 五、聚合短信+聚合支付(企業(yè)內(nèi)部升級(jí))
- 5.1. 相關(guān)SQL語(yǔ)句
- 5.2. 策略實(shí)體
- 5.3. 策略接口
- 5.4.策略上下文
- 5.5. 聚合短信和聚合支付測(cè)試
- 5.6. mapper掃描配置
- 5.7. 依賴(lài)
- 5.8. yml配置
- 5.9. 開(kāi)源地址
一、設(shè)計(jì)模式
1. 為什么需要使用設(shè)計(jì)模式
使用設(shè)計(jì)模式可以重構(gòu)整體架構(gòu)代碼、提交代碼復(fù)用性、擴(kuò)展性、減少代碼冗余問(wèn)題。
2. 設(shè)計(jì)模式的分類(lèi)
創(chuàng)建型模式
工廠方法模式、抽象工廠模式、單例模式、建造者模式、原型模式。
結(jié)構(gòu)型模式
適配器模式、裝飾器模式、代理模式、外觀模式、橋接模式、組合模式、享元模式
行為模式
策略模式、模板方法模式、觀察者模式、迭代子模式、責(zé)任鏈模式、命令模式、備忘錄模式、狀態(tài)模式、訪問(wèn)者模式、中介者模式、解釋器模式。
策略模式
3. 什么是策略模式
策略模式是對(duì)算法的包裝,是把使用算法的責(zé)任和算法本身分割開(kāi)來(lái),委派給不同的對(duì)象管理,最終可以實(shí)現(xiàn)解決多重if判斷問(wèn)題。
1.環(huán)境(Context)角色:持有一個(gè)Strategy的引用。
2.抽象策略(Strategy)角色:這是一個(gè)抽象角色,通常由一個(gè)接口或抽象類(lèi)實(shí)現(xiàn)。此角色給出所有的具體策略類(lèi)所需的接口。
3.具體策略(ConcreteStrategy)角色:包裝了相關(guān)的算法或行為。
定義策略接口->實(shí)現(xiàn)不同的策略類(lèi)->利用多態(tài)或其他方式調(diào)用策略
4. 為什么叫做策略模式
每個(gè)if判斷都可以理解為就是一個(gè)策略。
5. 策略模式優(yōu)缺點(diǎn)
優(yōu)點(diǎn)
算法可以自由切換(高層屏蔽算法,角色自由切換)
避免使用多重條件判斷(如果算法過(guò)多就會(huì)出現(xiàn)很多種相同的判斷,很難維護(hù))
擴(kuò)展性好(可自由添加取消算法 而不影響整個(gè)功能)
缺點(diǎn)
策略類(lèi)數(shù)量增多(每一個(gè)策略類(lèi)復(fù)用性很小,如果需要增加算法,就只能新增類(lèi))
所有的策略類(lèi)都需要對(duì)外暴露(使用的人必須了解使用策略,這個(gè)就需要其它模式來(lái)補(bǔ)充,比如工廠模式、代理模式)
6. 策略模式應(yīng)用場(chǎng)景
聚合支付平臺(tái)
比如搭建聚合支付平臺(tái)的時(shí)候,這時(shí)候需要對(duì)接很多第三方支付接口,比如支付寶、微信支付、小米支付等。
通過(guò)傳統(tǒng)if代碼判斷的,后期的維護(hù)性非常差!
這時(shí)候可以通過(guò)策略模式解決多重if判斷問(wèn)題。
7. Spring框架中使用的策略模式
ClassPathXmlApplicationContext Spring底層Resource接口采用策略模式
Spring 為 Resource 接口提供了如下實(shí)現(xiàn)類(lèi):
UrlResource:訪問(wèn)網(wǎng)絡(luò)資源的實(shí)現(xiàn)類(lèi)。
ClassPathResource:訪問(wèn)類(lèi)加載路徑里資源的實(shí)現(xiàn)類(lèi)。
FileSystemResource:訪問(wèn)文件系統(tǒng)里資源的實(shí)現(xiàn)類(lèi)。
ServletContextResource:訪問(wèn)相對(duì)于 ServletContext 路徑里的資源的實(shí)現(xiàn)類(lèi):
InputStreamResource:訪問(wèn)輸入流資源的實(shí)現(xiàn)類(lèi)。
ByteArrayResource:訪問(wèn)字節(jié)數(shù)組資源的實(shí)現(xiàn)類(lèi)。
1、new ClassPathXmlApplicationContext("");
2.進(jìn)入該構(gòu)造函數(shù)
4.SpringBean初始化 SimpleInstantiationStrategy
SimpleInstantiationStrategy 簡(jiǎn)單初始化策略
CglibSubclassingInstantiationStrategy CGLIB初始化策略
二、策略模式~聚合短信服務(wù)
2.1. 依賴(lài)引入
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.6.4</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.gblfy</groupId><artifactId>design-pattern</artifactId><version>0.0.1-SNAPSHOT</version><name>design-pattern</name><description>design-pattern</description><properties><java.version>1.8</java.version></properties><dependencies><!--字符串工具類(lèi)--><dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>3.12.0</version></dependency><!--數(shù)據(jù)json處理--><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.2.79</version></dependency><!--SpringMVC--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><excludes><exclude><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></exclude></excludes></configuration></plugin></plugins></build></project>2.2. 抽象公共行為接口
MsgStrategy
package com.gblfy.strategy;/*** 抽象公共行為接口** @author gblfy* @date 2022-03-13*/ public interface MsgStrategy {/*** 共同行為方法** @param phone* @return*/String sendMsg(String phone); }2.3. 具體策略接口實(shí)現(xiàn)類(lèi)
調(diào)用(阿里云)短信息服務(wù)
package com.gblfy.strategy.impl;import com.gblfy.strategy.MsgStrategy; import org.springframework.stereotype.Service;/*** 調(diào)用(阿里云)短信息服務(wù)** @author gblfy* @date 2022-03-13*/ @Service public class AliYunStrategy implements MsgStrategy {@Overridepublic String sendMsg(String phone) {return "調(diào)用(阿里云)短信息服務(wù)";} }調(diào)用(華為云)短信息服務(wù)
package com.gblfy.strategy.impl;import com.gblfy.strategy.MsgStrategy; import org.springframework.stereotype.Service;/*** 調(diào)用(華為云)短信息服務(wù)** @author gblfy* @date 2022-03-13*/ @Service public class HuaWeiStrategy implements MsgStrategy {@Overridepublic String sendMsg(String phone) {return "調(diào)用(華為云)短信息服務(wù)";} }調(diào)用(騰訊云)短信息服務(wù)
package com.gblfy.strategy.impl;import com.gblfy.strategy.MsgStrategy; import org.springframework.stereotype.Service;/*** 調(diào)用(騰訊云)短信息服務(wù)** @author gblfy* @date 2022-03-13*/ @Service public class TencentStrategy implements MsgStrategy {@Overridepublic String sendMsg(String phone) {return "調(diào)用(騰訊云)短信息服務(wù)";} }2.4. 策略枚舉
package com.gblfy.enums;/*** 策略枚舉,存放所有策略的實(shí)現(xiàn)** @author gblfy* @date 2022-03-13*/ public enum SmsEnumStrategy {/*** 支付寶短信*/ALI_SMS("com.gblfy.strategy.impl.AliYunStrategy"),/*** 華為云短信*/HUAWEI_SMS("com.gblfy.strategy.impl.HuaWeiStrategy"),/*** 騰訊云短信*/TENCENT_SMS("com.gblfy.strategy.impl.TencentStrategy");/*** class 名稱(chēng)*/private String className;SmsEnumStrategy(String className) {this.setClassName(className);}public String getClassName() {return className;}public void setClassName(String className) {this.className = className;} }2.5. 獲取具體策略實(shí)現(xiàn)
package com.gblfy.strategy;import com.gblfy.factory.StrategyFactory; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component;/*** 獲取具體策略實(shí)現(xiàn)** @author gblfy* @date 2022-03-13*/ @Component public class SmsContextStrategy {/*** 獲取具體策略實(shí)現(xiàn)*/public String getStrategy(String strategyId, String phone) {if (StringUtils.isEmpty(strategyId)) {return "paycode 不能為空";}// 第1種:使用策略工廠獲取具體策略的實(shí)現(xiàn)MsgStrategy msgStrategy = StrategyFactory.getPayStrategy(strategyId);if (msgStrategy == null) {return ",沒(méi)有找到具體策略的實(shí)現(xiàn)...";}return msgStrategy.sendMsg(phone);} }2.6. 策略工廠
package com.gblfy.factory;import com.gblfy.enums.SmsEnumStrategy; import com.gblfy.strategy.MsgStrategy;/*** 使用策略工廠獲取具體策略實(shí)現(xiàn)** @author gblfy* @date 2022-03-13*/ public class StrategyFactory {//工廠初始化public static MsgStrategy getPayStrategy(String strategyType) {try {// 1.獲取枚舉中classNameString className = SmsEnumStrategy.valueOf(strategyType).getClassName();// 2.使用java反射技術(shù)初始化類(lèi)return (MsgStrategy) Class.forName(className).newInstance();} catch (Exception e) {return null;}} }2.7. 聚合短信服務(wù)測(cè)試
/*** 測(cè)試鏈接:* http://localhost:8080/sendMsgByEnumSfactory?strategyId=ALI_SMS&phone=123456* http://localhost:8080/sendMsgByEnumSfactory?strategyId=HUAWEI_SMS&phone=123456* http://localhost:8080/sendMsgByEnumSfactory?strategyId=TENCENT_SMS&phone=123456*/ package com.gblfy.controller;import com.gblfy.strategy.SmsContextStrategy; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController;@RestController public class MsgController {@Autowiredprivate SmsContextStrategy contextStrategy;/*** 使用枚舉+工廠+策略模式實(shí)現(xiàn)聚合短信服務(wù)* * @param strategyId 策略ID* @param phone 手機(jī)號(hào)碼* @return*/@GetMapping("/sendMsgByEnumSfactory")public String sendMsgByEnumSfactory(@RequestParam("strategyId") String strategyId,@RequestParam("phone") String phone) {return contextStrategy.getStrategy(strategyId, phone);}/*** 測(cè)試鏈接:* http://localhost:8080/sendMsgByEnumSfactory?strategyId=ALI_SMS&phone=123456* http://localhost:8080/sendMsgByEnumSfactory?strategyId=HUAWEI_SMS&phone=123456* http://localhost:8080/sendMsgByEnumSfactory?strategyId=TENCENT_SMS&phone=123456*/ }三、聚合短信服務(wù)2
1.使用工廠模式初始化具體策略class
2.將所有具體實(shí)現(xiàn)的策略存放到map集合中(枚舉類(lèi)中)
3.key:ALI_PAY value:com.gblfy.service.AliPayStrategy
3.1. 策略工廠調(diào)整
package com.gblfy.factory;import com.gblfy.strategy.MsgStrategy; import com.gblfy.strategy.impl.AliYunStrategy; import com.gblfy.strategy.impl.HuaWeiStrategy; import com.gblfy.strategy.impl.TencentStrategy;import java.util.Map; import java.util.concurrent.ConcurrentHashMap;public class FactoryStrategy {private static Map<String, MsgStrategy> msgStrategyMap = new ConcurrentHashMap<>();static {msgStrategyMap.put("huawei", new HuaWeiStrategy());msgStrategyMap.put("tencent", new TencentStrategy());msgStrategyMap.put("aliyun", new AliYunStrategy());}public static MsgStrategy getContextStrategy(String strategyId) {return msgStrategyMap.get(strategyId);} }3.2. 聚合短信測(cè)試
package com.gblfy.controller;import com.gblfy.factory.FactoryStrategy; import com.gblfy.strategy.MsgStrategy; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController;@RestController public class MsgController {/*** 使用工廠+策略模式實(shí)現(xiàn)聚合短信服務(wù)** @param strategyId* @param phone* @return*/@GetMapping("/sendMsgByfactory")public String sendMsgByfactory(@RequestParam("strategyId") String strategyId,@RequestParam("phone") String phone) {MsgStrategy contextStrategy = FactoryStrategy.getContextStrategy(strategyId);return contextStrategy.sendMsg(phone);}/*** 測(cè)試鏈接:* http://localhost:8080/sendMsgByfactory?strategyId=huawei&phone=123456* http://localhost:8080/sendMsgByfactory?strategyId=tencent&phone=123456* http://localhost:8080/sendMsgByfactory?strategyId=aliyun&phone=123456*/ }四、聚合短信3
使用springIOC代替反射,提高效率,動(dòng)態(tài)切換(無(wú)需改動(dòng)項(xiàng)目)
4.1. 策略上下文
package com.gblfy.strategy;import com.gblfy.utils.SpringContextUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component;@Component public class StrategyContext {public MsgStrategy getStrategy(String strategyId) {if (StringUtils.isEmpty(strategyId)) {return null;}return SpringContextUtils.getBean(strategyId, MsgStrategy.class);}}4.2. SpringContext上下文工具類(lèi)
package com.gblfy.utils;import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component;/*** 獲取Spring上下文工具類(lèi)** @author gblfy* @date 2022-03-13*/ @Component public class SpringContextUtils implements ApplicationContextAware {private static ApplicationContext applicationContext;@Overridepublic void setApplicationContext(ApplicationContext applicationContext) throws BeansException {SpringContextUtils.applicationContext = applicationContext;}//獲取applicationContextpublic static ApplicationContext getApplicationContext() {return applicationContext;}//通過(guò)name獲取 Bean.public static Object getBean(String name) {return getApplicationContext().getBean(name);}//通過(guò)class獲取Bean.public static <T> T getBean(Class<T> clazz) {return getApplicationContext().getBean(clazz);}//通過(guò)name,以及Clazz返回指定的Beanpublic static <T> T getBean(String name, Class<T> clazz) {return getApplicationContext().getBean(name, clazz);}}4.3. 聚合短信測(cè)試
/*** 使用工廠+策略模式+SpringIOC實(shí)現(xiàn)聚合短信服務(wù)** @param strategyId* @param phone* @return*/@GetMapping("/sendMsgBySpringIOC")public String sendMsgBySpringIOC(@RequestParam("strategyId") String strategyId,@RequestParam("phone") String phone) {MsgStrategy contextStrategy = strategyContext.getStrategy(strategyId);return contextStrategy.sendMsg(phone);}/*** 測(cè)試鏈接:* http://localhost:8080/sendMsgBySpringIOC?strategyId=aliYunStrategy&phone=123456* http://localhost:8080/sendMsgBySpringIOC?strategyId=huaWeiStrategy&phone=123456* http://localhost:8080/sendMsgBySpringIOC?strategyId=tencentStrategy&phone=123456*/五、聚合短信+聚合支付(企業(yè)內(nèi)部升級(jí))
5.1. 相關(guān)SQL語(yǔ)句
drop database IF EXISTS `design_pattern`; create database `design_pattern`; use `design_pattern`;SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0;-- ---------------------------- -- Table structure for gblfy_strategy -- ---------------------------- DROP TABLE IF EXISTS `gblfy_strategy`; CREATE TABLE `gblfy_strategy` (`id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',`strategy_name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '策略名稱(chēng)',`strategy_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '策略ID',`strategy_type` int NOT NULL COMMENT '策略類(lèi)型(0-支付服務(wù),1-短信服務(wù))',`strategy_bean_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '策略執(zhí)行beanid實(shí)例',`deleted` int NOT NULL COMMENT '邏輯刪除字段(0-有效 1-無(wú)效,默認(rèn)為0)',PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '策略配置表' ROW_FORMAT = Dynamic;-- ---------------------------- -- Records of gblfy_strategy -- ---------------------------- INSERT INTO `gblfy_strategy` VALUES (6, '騰訊云短信', 'tencent_sms', 1, 'tencentStrategy', 0); INSERT INTO `gblfy_strategy` VALUES (7, '阿里云短信', 'aliYun_sms', 1, 'aliYunStrategy', 0); INSERT INTO `gblfy_strategy` VALUES (8, '華為云短信', 'huaWei_sms', 1, 'huaWeiStrategy', 0); INSERT INTO `gblfy_strategy` VALUES (9, '阿里支付', 'ali_pay', 0, 'aliPayStrategy', 0); INSERT INTO `gblfy_strategy` VALUES (10, '銀聯(lián)支付', 'yinlian_pay', 0, 'unionPayStrategy', 0);SET FOREIGN_KEY_CHECKS = 1;5.2. 策略實(shí)體
package com.gblfy.entity;import com.baomidou.mybatisplus.annotation.*; import lombok.Data;@Data @TableName("gblfy_strategy") public class GblfyStrategy {// 策略配置主鍵@TableId(value = "id", type = IdType.ASSIGN_ID)private Long id;//策略名稱(chēng)(阿里云短信、銀聯(lián)支付)@TableField("strategy_name")private String strategyName;//策略ID@TableField("strategy_id")private String strategyId;//策略類(lèi)型(發(fā)短信或者調(diào)用支付)@TableField("strategy_type")private String strategyType;//策略具體執(zhí)行beanId@TableField("strategy_bean_id")private String strategyBeanId;//邏輯刪除字段@TableLogicprivate Integer deleted; }5.3. 策略接口
package com.gblfy.mapper;import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.gblfy.entity.GblfyStrategy;/*** 策略接口** @author gblfy* @date 2022-03-13*/ public interface StragegyMapper extends BaseMapper<GblfyStrategy> { }5.4.策略上下文
package com.gblfy.strategy;import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.gblfy.entity.GblfyStrategy; import com.gblfy.mapper.StragegyMapper; import com.gblfy.utils.SpringContextUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component;@Component public class StrategyContext {@Autowiredprivate StragegyMapper stragegyMapper;// public MsgStrategy getStrategy(String strategyId) {// if (StringUtils.isEmpty(strategyId)) {// return null;// }// return SpringContextUtils.getBean(strategyId, MsgStrategy.class);// }// public <T> T getStrategy(String stragegyId,Class<T> t){// if (StringUtils.isEmpty(stragegyId)){// return null;// }// return SpringContextUtils.getBean(stragegyId, t);// }public <T> T getStrategy(String stragegyId, String stragegyType, Class<T> t) {if (StringUtils.isEmpty(stragegyId)) {return null;}if (StringUtils.isEmpty(stragegyType)) {return null;}if (t == null) {return null;}//根據(jù)策略id和策略類(lèi)型查詢(xún)具體策略實(shí)例beanIdGblfyStrategy gblfyStrategy = stragegyMapper.selectOne(new QueryWrapper<GblfyStrategy>().lambda().eq(GblfyStrategy::getStrategyId, stragegyId).eq(GblfyStrategy::getStrategyType, stragegyType));if (gblfyStrategy == null) {return null;}String strategyBeanId = gblfyStrategy.getStrategyBeanId();if (StringUtils.isEmpty(strategyBeanId)) {return null;}return SpringContextUtils.getBean(strategyBeanId, t);} }5.5. 聚合短信和聚合支付測(cè)試
/*** 多個(gè)不同服務(wù)(短信+支付)抽象封裝* mysql+SpringIOC+策略模式實(shí)現(xiàn)聚合短信服務(wù)和聚合支付服務(wù)** @param strategyId* @param stragegyType* @param phone* @return*/@GetMapping("/sendMsgByMysqlAndSpringIOC")public String sendMsgBySpringIOC(@RequestParam("strategyId") String strategyId,@RequestParam("stragegyType") String stragegyType,@RequestParam("phone") String phone) {MsgStrategy strategy = strategyContext.getStrategy(strategyId, stragegyType, MsgStrategy.class);if (strategy == null) {return "當(dāng)前渠道已關(guān)閉或者不存在,請(qǐng)核實(shí)!";}return strategy.sendMsg(phone);}/*** 測(cè)試鏈接(聚合短信):* http://localhost:8080/sendMsgByMysqlAndSpringIOC?strategyId=ali_pay&stragegyType=1&phone=123456* http://localhost:8080/sendMsgByMysqlAndSpringIOC?strategyId=ali_pay&stragegyType=1&phone=123456* http://localhost:8080/sendMsgByMysqlAndSpringIOC?strategyId=ali_pay&stragegyType=1&phone=123456** 測(cè)試鏈接(聚合支付):* http://localhost:8080/sendMsgByMysqlAndSpringIOC?strategyId=ali_pay&stragegyType=0&phone=123456*/5.6. mapper掃描配置
package com.gblfy.config;import org.mybatis.spring.annotation.MapperScan; import org.springframework.context.annotation.Configuration;@Configuration @MapperScan("com.gblfy.mapper") public class MybatisPlusConfig {}5.7. 依賴(lài)
<!--mybatis-plus 持久化--><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.5.1</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><scope>runtime</scope></dependency>5.8. yml配置
server:port: 8080 spring:datasource:username: rootpassword: 123456driver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://127.0.0.1:3306/design_pattern?useUnicode=true&characterEncoding=UTF-8 logging:level:com.gblfy.mapper: DEBUG mybatis-plus:configuration:log-impl:mapper-locations: classpath:mappers/*.xml5.9. 開(kāi)源地址
https://gitee.com/gblfy/design-pattern
總結(jié)
以上是生活随笔為你收集整理的精讲23种设计模式-策略模式~聚合短信服务和聚合支付服务的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: MyBatis 配置文件 用户密码加密存
- 下一篇: 使用MultipartFile实现文件上