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

做外汇哪个网站看外国消息saas小程序开发费用

做外汇哪个网站看外国消息,saas小程序开发费用,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/83262/

相关文章:

  • wordpress网站页面打开很慢集团品牌官网建设
  • 网站视频是什么软件做的中山做网站公司哪家好
  • 开公司 专做网站网站页面设计需求
  • 哈尔滨网站开发培训行业开发
  • 做国外lead应该做什么网站高端手机网站建设
  • 网站开发(七)数据库的建表与连接如何进外贸大公司网站
  • 做网站需要买多大空间做跨境网站
  • 网站推广服务商专做老酒的网站
  • 网站如何宣传推广泉州专业网站建设公司哪家好
  • wordpress也没修改福州seo技术培训
  • 网站建设公司广告语 宣传语自媒体平台有哪些
  • 做推广可以在哪些网站发布软文企业查询信息系统
  • 足球竞猜网站开发有网站源码怎么建站
  • 商丘公司做网站网站建设网站设计多少钱
  • wordpress google ua code 是什么网站seo优化外包顾问
  • 担路做网站王烨个人简历
  • 电子商务网站建设的目的是开展网络营销如何查询网站是织梦做的
  • 百度怎么推广网站网站建设费用大概多少
  • 浙江省建设信息港的网站品牌建设典型案例材料
  • 怎样在网站模板上做修改陆良县住房和城乡建设局网站
  • 价格网站网站标题如何设置
  • 微网站建设云帆网络网站建设自评报告
  • 网站服务器租用年度价格网站关键词标签
  • 上海最好的网站是什么做网站用织梦好吗
  • 网站开发方案书昆明网站建设_云南网站建设
  • 大连工业大学中外合作办学台州seo服务
  • 一个空间怎么放两个网站网络营销发展的趋势
  • 成都哪里做网站wordpress redirect_to
  • 黑龙江省建设集团网站南山优化网站建设案例
  • jsp商业网站开发安徽省公共资源交易中心网站