package com.moral.config;
|
import com.google.code.kaptcha.impl.DefaultKaptcha;
|
import com.google.code.kaptcha.util.Config;
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Configuration;
|
|
import java.util.Properties;
|
|
/**
|
* @ClassName KaptchaConfig
|
* @Description TODO
|
* @Author 陈凯裕
|
* @Date 2021/3/16 14:04
|
* @Version TODO
|
**/
|
@Configuration
|
public class KaptchaConfig {
|
|
@Bean(name = "kaptchaProducer")
|
public DefaultKaptcha getDefaultKaptcha(){
|
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
|
Properties properties = new Properties();
|
//设置边框
|
properties.put("kaptcha.border", "no");
|
//字体颜色
|
properties.put("kaptcha.textproducer.font.color", "blue");
|
//文字间隔
|
properties.put("kaptcha.textproducer.char.space", "15");
|
//验证码长度
|
properties.put("kaptcha.textproducer.char.length","4");
|
//图片高度
|
properties.put("kaptcha.image.height","34");
|
//文字尺寸
|
properties.put("kaptcha.textproducer.font.size","25");
|
//干扰实现类
|
/*不使用干扰*/
|
//properties.put("kaptcha.noise.impl","com.google.code.kaptcha.impl.NoNoise");
|
/*使用默认干扰实现类*/
|
properties.put("kaptcha.noise.impl","com.google.code.kaptcha.impl.DefaultNoise");
|
//字体
|
//properties.setProperty("kaptcha.textproducer.font.names", "宋体");
|
|
Config config = new Config(properties);
|
defaultKaptcha.setConfig(config);
|
return defaultKaptcha;
|
}
|
}
|