com.maxiaofa.captcha.spring.boot.config.RotateCaptchaAutoConfiguration Maven / Gradle / Ivy
package com.maxiaofa.captcha.spring.boot.config;
import com.maxiaofa.captcha.Constants;
import com.maxiaofa.captcha.impl.RotateCaptcha;
import com.maxiaofa.captcha.utils.Config;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import com.maxiaofa.captcha.spring.boot.properties.RotateCaptchaProperties;
import java.util.Properties;
/**
* 自动装配
* @author MaXiaoFa
*
*/
@Configuration
@ComponentScan("com.maxiaofa.captcha.spring.boot")
@EnableConfigurationProperties(value = RotateCaptchaProperties.class)
public class RotateCaptchaAutoConfiguration {
@Bean(name = "rotateCaptchaProducer")
public RotateCaptcha getRotateCaptchaBean(RotateCaptchaProperties rotateCaptchaProperties) {
RotateCaptcha rotateCaptcha = new RotateCaptcha();
Properties properties = new Properties();
properties.setProperty(Constants.CAPTCHA_ROTATION_ANGLE_OFFSET,String.valueOf(rotateCaptchaProperties.getAngleOffset()));
properties.setProperty(Constants.CAPTCHA_ROTATION_ANGLE_MAX,String.valueOf(rotateCaptchaProperties.getAngleMax()));
properties.setProperty(Constants.CAPTCHA_ROTATION_ANGLE_MIN,String.valueOf(rotateCaptchaProperties.getAngleMin()));
properties.setProperty(Constants.CAPTCHA_ROTATION_FAULT,String.valueOf(rotateCaptchaProperties.getFault()));
Config config = new Config(properties);
rotateCaptcha.setConfig(config);
return rotateCaptcha;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy