@Bean(autowire = Autowire.BY_NAME,value = "kaptchaProducer")
public Producer kaptchaProducer() {
Properties kaptchaProperties = new Properties();
kaptchaProperties.put("kaptcha.border", "no");
kaptchaProperties.put("kaptcha.textproducer.char.length","4");
kaptchaProperties.put("kaptcha.image.height","50");
kaptchaProperties.put("kaptcha.image.width","150");
kaptchaProperties.put("kaptcha.obscurificator.impl","com.google.code.kaptcha.impl.ShadowGimpy");
kaptchaProperties.put("kaptcha.textproducer.font.color","black");
kaptchaProperties.put("kaptcha.textproducer.font.size","40");
kaptchaProperties.put("kaptcha.noise.impl","com.google.code.kaptcha.impl.NoNoise");
//kaptchaProperties.put("kaptcha.noise.impl","com.google.code.kaptcha.impl.DefaultNoise");
kaptchaProperties.put("kaptcha.textproducer.char.string","acdefhkmnprtwxy2345678"); Config config = new Config(kaptchaProperties);
return config.getProducerImpl();
} @Bean(autowire = Autowire.BY_NAME,value = "kaptchaProducerH5")
public Producer kaptchaProducerH5() {
Properties kaptchaProperties = new Properties();
kaptchaProperties.put("kaptcha.border", "no");
kaptchaProperties.put("kaptcha.textproducer.char.length","4");
kaptchaProperties.put("kaptcha.image.height","50");
kaptchaProperties.put("kaptcha.image.width","150");
kaptchaProperties.put("kaptcha.obscurificator.impl","com.google.code.kaptcha.impl.ShadowGimpy");
kaptchaProperties.put("kaptcha.textproducer.font.color","black");
kaptchaProperties.put("kaptcha.textproducer.font.size","40");
kaptchaProperties.put("kaptcha.noise.impl","com.google.code.kaptcha.impl.NoNoise");
//kaptchaProperties.put("kaptcha.noise.impl","com.google.code.kaptcha.impl.DefaultNoise");
kaptchaProperties.put("kaptcha.textproducer.char.string","0123456789"); Config config = new Config(kaptchaProperties);
return config.getProducerImpl();
}

  

    @Resource(name = "kaptchaProducer")
private Producer kaptchaProducer; @Resource(name = "kaptchaProducerH5")
private Producer kaptchaProducerH5;

  

SpringBoot中实现Spring容器中注入类型相同但名不同Bean的更多相关文章

  1. 在listener或者工具中使用spring容器中的bean实例

    在项目中经常遇见需要在Listener中或者工具中使用Spring容器中的bean实例,由于bean不能在stataic的类中使用. 介绍一种方式: public class SpringTool { ...

  2. 普通类中获取spring容器中的javabean对象

    spring提供了一系列的*Aware 接口,用于获取相应的对象,进行一系列的对象设置操作,此处实现ApplicationContextAware来获取ApplicationContext. 其他Aw ...

  3. [十]SpringBoot 之 普通类获取Spring容器中的bean

    我们知道如果我们要在一个类使用spring提供的bean对象,我们需要把这个类注入到spring容器中,交给spring容器进行管理,但是在实际当中,我们往往会碰到在一个普通的Java类中,想直接使用 ...

  4. SpringBoot 之 普通类获取Spring容器中的bean

    [十]SpringBoot 之 普通类获取Spring容器中的bean   我们知道如果我们要在一个类使用spring提供的bean对象,我们需要把这个类注入到spring容器中,交给spring容器 ...

  5. 基于ImportBeanDefinitionRegistrar和FactoryBean动态注入Bean到Spring容器中

    基于ImportBeanDefinitionRegistrar和FactoryBean动态注入Bean到Spring容器中 一.背景 二.实现方案 1.基于@ComponentScan注解实现 2.基 ...

  6. java 从spring容器中获取注入的bean对象

      java 从spring容器中获取注入的bean对象 CreateTime--2018年6月1日10点22分 Author:Marydon 1.使用场景 控制层调用业务层时,控制层需要拿到业务层在 ...

  7. Servlet自动注入Spring容器中的Bean解决方法

    很多情况在进行Web开发的时候需要自己手写Servlet来完成某些功能,而servlet有需要注入Spring容器中的某些bean,这是每次都要手动获取比较麻烦,这里有一个解决方案,只需要写一个ser ...

  8. 从spring容器中取出注入的bean

    从spring容器中取出注入的bean 工具类,代码如下: package com.hyzn.fw.util; import org.springframework.beans.BeansExcept ...

  9. Spring管理Filter和Servlet(在servlet中注入spring容器中的bean)

    在使用spring容器的web应用中,业务对象间的依赖关系都可以用context.xml文件来配置,并且由spring容器来负责依赖对象 的创建.如果要在servlet中使用spring容器管理业务对 ...

随机推荐

  1. mapreduce 函数入门 三

    一.mapreduce多job串联 1.需求 一个稍复杂点的处理逻辑往往需要多个 mapreduce 程序串联处理,多 job 的串联可以借助 mapreduce 框架的 JobControl 实现 ...

  2. PHP正则匹配网址

    /** * @param $url 网址 * @return bool */ public static function checkUrl($url){ $pattern="/^(http ...

  3. idea pycharm 常用快捷键

    Ctrl + P 方法参数提示显示 (必备)Alt + Enter 根据光标所在问题,提供快速修复选择,光标放在的位置不同提示的结果也不同 (必备)Ctrl + / 行注释(可选中多行)Ctrl + ...

  4. 【转帖】威盛x86 AI处理器架构、性能公布:媲美Intel 32核心

    威盛x86 AI处理器架构.性能公布:媲美Intel 32核心 https://www.cnbeta.com/articles/tech/920559.htm 除了Intel.AMD,宝岛台湾的威盛也 ...

  5. Python-06-函数

    一.函数的定义 函数是第一类对象,即函数可以当作数据传递 #1 可以被引用 #2 可以当作参数传递 #3 返回值可以是函数 #3 可以当作容器类型的元素 1. 定义方式 def 函数名(参数1,参数2 ...

  6. trie、FSA、FST(转)

    add by zhj: 在学习Lucene的存储结构时,看到其使用了FST,这篇文章写的不错. trie,FSA,FST都是用来解决有限状态机的存储,trie是树,它进一步演化为FSA和FST,这两者 ...

  7. c# 创建Excel com加载项Ribbon动态加载工作簿和工作表

    使用 VSTO 创建外接程序,Gallery控件动态加载工作簿名称 代码如下: 加载工作簿名称: private void Gallery1_ItemsLoading(object sender, R ...

  8. Java自学-数字与字符串 字符串转换

    Java中把数字转换为字符串,字符串转换为数字 步骤 1 : 数字转字符串 方法1: 使用String类的静态方法valueOf 方法2: 先把基本类型装箱为对象,然后调用对象的toString pa ...

  9. vue-cli 3.x版本执行vue ui命令后提示Error: Cannot find module ‘core-js/modules/es7.object.entries’报错的解决方法

    我的方法是:npm install --save core-js(全局安装竟然不行,必须局部) vue-cli新版提供了界面化项目管理的功能,简直一万个赞! 在安装 vue-cli 3.x  版本后, ...

  10. Django2.2 pymysql 连接mysql数据库的坑

    参考链接 https://www.52pojie.cn/thread-921141-1-1.html 1. mysqlclient 1.3版本不对 解决办法:注释掉D:\Users\xxx\AppDa ...