![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
spring
qq_43414291
这个作者很懒,什么都没留下…
展开
-
开闭原则spring中的解决方式
需求:完成支付模块需要支持微信支付,支付宝支付,通过传入code区分不同的支付方式,完成不同的支付逻辑我们首先想到的是用if 判断支付方式 :if(payType.getCode == 101){ // 支付宝支付} else if(payType.getCode == 102){ // 微信支付逻辑}但是如果我们需要增加一个银联支付,则需要继续改动业务逻辑,添加更多的if else,这样明显不符合设计原则中的开闭原则:对扩展开放,对修改关闭所以产生了如下的解决方式:PayCod原创 2020-12-23 21:31:20 · 287 阅读 · 0 评论 -
spring中自定义properties编辑器PropertyEditorRegistrar、PropertyEditorSupport的使用
需求:如何如下properties填充到对应如下两个对象中呢?customer.name=小术customer.address=湖北_武汉_黄陂@Datapublic class Customer { @Value("${customer.name}") private String name; @Value("${customer.address}") private Address address;}@Datapublic class Addres.原创 2020-12-15 19:07:02 · 1004 阅读 · 3 评论