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;
    

      

  • 相关阅读:
    Eclipse配置Struts2
    Servlet读取头信息
    JAVA基础
    Start Tomcat v8.0 Server at localhost错误
    Eclipse 配置Server Location时灰色,不可用
    Windows 7安装apache-tomcat-8.0.24
    Sql developer——缺点
    Oracle Database,SQL Server,MySQL的比较
    poj1580---欧几里得算法(辗转相除法)
    poj1565---(数论)skew binary
  • 原文地址:https://www.cnblogs.com/jtlgb/p/11796716.html
Copyright © 2011-2022 走看看