SpringBoot名が異なるビーンのSpringコンテナを達成するために、注射の同じタイプ

    @Bean(autowire = Autowire.BY_NAME、値= "kaptchaProducer")
    公衆プロデューサーkaptchaProducer(){ 
        プロパティkaptchaProperties =新しいプロパティ(); 
        kaptchaProperties.put( "kaptcha.border"、 "なし"); 
        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"、 "黒")。
        kaptchaProperties.put(」
        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"); 

        コンフィグ設定=新しい設定(kaptchaProperties)。
        config.getProducerImplを返します(); 
    } 

    @Bean(autowire = Autowire.BY_NAME、値= "kaptchaProducerH5")
    公衆プロデューサーkaptchaProducerH5(){ 
        プロパティkaptchaPropertiesは=新しいプロパティ(); 
        kaptchaProperties.put( "kaptcha.border"、 "なし"); 
        kaptchaProperties.put(「kaptcha。
        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"、 "黒")。
        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"); 

        コンフィグ設定=新しい設定(kaptchaProperties)。
        config.getProducerImplを返します(); 
    }

  

    @Resource(名前= "kaptchaProducer")
    プライベートプロデューサーkaptchaProducer。

    @Resource(名前= "kaptchaProducerH5")
    プライベートプロデューサーkaptchaProducerH5。

  

おすすめ

転載: www.cnblogs.com/jtlgb/p/11796716.html