当前位置: 首页 > news >正文

ppt模板去哪个网站下载Wordpress一写文章就卡了

ppt模板去哪个网站下载,Wordpress一写文章就卡了,网站开发支持二次开发,wordpress如何上传视频前言 最近看到RuoYi-Vue-Plus翻译功能 Translation的翻译模块配置类TranslationConfig,其中有一个注入TranslationInterface翻译接口实现类的写法让我感到很新颖,但这种写法在Spring 3.0版本以后就已经支持注入List和Map,平时都没有注意到这…

前言

最近看到RuoYi-Vue-Plus翻译功能 Translation的翻译模块配置类TranslationConfig,其中有一个注入TranslationInterface翻译接口实现类的写法让我感到很新颖,但这种写法在Spring 3.0版本以后就已经支持注入ListMap,平时都没有注意到这一块,故此记录一下这种写法。

翻译模块配置类

TranslationConfig这里是翻译配置初始化的地方

package com.ruoyi.framework.config;import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.common.annotation.TranslationType;
import com.ruoyi.common.translation.TranslationInterface;
import com.ruoyi.common.translation.handler.TranslationBeanSerializerModifier;
import com.ruoyi.common.translation.handler.TranslationHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;/*** 翻译模块配置类** @author Lion Li*/
@Slf4j
@Configuration
public class TranslationConfig {@Autowiredprivate List<TranslationInterface<?>> list;@Autowiredprivate ObjectMapper objectMapper;@PostConstructpublic void init() {Map<String, TranslationInterface<?>> map = new HashMap<>(list.size());for (TranslationInterface<?> trans : list) {if (trans.getClass().isAnnotationPresent(TranslationType.class)) {TranslationType annotation = trans.getClass().getAnnotation(TranslationType.class);map.put(annotation.type(), trans);} else {log.warn(trans.getClass().getName() + " 翻译实现类未标注 TranslationType 注解!");}}TranslationHandler.TRANSLATION_MAPPER.putAll(map);// 设置 Bean 序列化修改器objectMapper.setSerializerFactory(objectMapper.getSerializerFactory().withSerializerModifier(new TranslationBeanSerializerModifier()));}}

可以看到在这个配置类中注入了一个List集合,其类型为TranslationInterface翻译接口

我们来看一下它的实现类

这些实现类定义在common模块的translation包下,分别是部门字典OSS用户名的翻译实现

Spring会扫描TranslationInterface翻译接口实现类注入到List

我们来Debug看一下效果,可以看到TranslationInterface翻译接口的实现类确实全部已经注入进来了

由于@Autowired注解还可以注入BeanMap中,这里我们手动加上Map集合,Debug断点调试一下:

http://www.yayakq.cn/news/236228/

相关文章:

  • 建站中企动力昆明网架公司
  • 安徽合肥建设厅网站广东深圳网站设计室
  • 金融商城快捷申请网站模板下载网站开发 工资高吗
  • 网站开发计入什么科目wordpress建站知乎
  • 做视频链接的网站备案怎么关闭网站
  • 无锡企业网站做p2p网站的主页模板
  • 网站系统下载不了文件芜湖有哪些知名企业
  • 怎么在网站上做视频seo营销推广平台
  • 阜阳网站开发中国企业500强2018
  • 江苏交通厅门户网站建设工程国际交流合作网站建设方案
  • 中国室内设计网站排名做外贸需要具备什么条件
  • 用阿里云做网站会不会被黑网站项目建设策划方案
  • 网站视觉设计谷歌浏览器网页版入口
  • 国外建站工具北京网站建设的服务
  • 一起做网店网站入驻收费合肥建设学校网站首页
  • 网站建设 橙建筑施工企业主要负责人安全证书
  • 建立带数据库的网站广州联雅网络科技有限公司
  • 哈尔滨 做网站公司有哪些网上室内设计师培训
  • 京东这样的网站怎么做国际招聘人才网
  • 四川微信网站建设推广怎么做58同城网站
  • iis部署网站项目go做的网站
  • 天津做网站报价外贸企业网站功能要求
  • 免费网站建设排名新媒体 数字营销 网站建设
  • 基于j2ee的网站开发设计开题报告5年网站续费多少钱
  • 可以做烟的网站吗下载百度手机助手
  • 用个人电脑做网站服务器软文营销文章500字
  • wordpress 人物页面长春网站排名优化费用
  • 天津建设合同备案网站广州好玩的地方和景点
  • 北安网站设计网络营销服务
  • 自助免费建站系统最旺的公司名称大全