zoukankan      html  css  js  c++  java
  • SpringBoot中实现Spring容器中注入类型相同但名不同Bean

        @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;
    

      

  • 相关阅读:
    rattle: Graphical user interface for data mining in R
    分享:下一代 Hadoop YARN 简介:相比于MRv1,YARN的优势
    djscaffold(Django)
    分享:TideSDK Demo
    青橙CEO蔡晓农:给大众高性价比智能机
    电脑公司Windows7旗舰版Ghost_Win7_64位_Ultimate_201210装机版
    分享:下一代 Hadoop YARN 简介:相比于MRv1,YARN的优势
    ghost win7,windows7系统之家,win7 64位旗舰版下载,win7系统下载
    phpMyAdmin or phpPgAdmin
    Python virtualenv
  • 原文地址:https://www.cnblogs.com/jtlgb/p/11796716.html
Copyright © 2011-2022 走看看