35 lines
1.6 KiB
Java
35 lines
1.6 KiB
Java
package com.nbclass.config;
|
||
|
||
import java.util.Properties;
|
||
|
||
import org.springframework.context.annotation.Bean;
|
||
import org.springframework.stereotype.Component;
|
||
|
||
import com.google.code.kaptcha.impl.DefaultKaptcha;
|
||
import com.google.code.kaptcha.util.Config;
|
||
|
||
/**
|
||
* kaptcha验证码参数配置
|
||
* @author Leon
|
||
* @datetime 2019年4月17日 上午10:23:09
|
||
*/
|
||
@Component
|
||
public class KaptchaConfig {
|
||
@Bean
|
||
public DefaultKaptcha getDefaultKaptcha(){
|
||
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
|
||
Properties properties = new Properties();
|
||
properties.setProperty("kaptcha.border", "no"); // 图片边框,合法值:yes , no
|
||
properties.setProperty("kaptcha.border.color", "105,179,90"); // 边框颜色,合法值: r,g,b (and optional alpha) 或者 white,black,blue.
|
||
properties.setProperty("kaptcha.textproducer.font.color", "black"); // 字体颜色,合法值: r,g,b 或者 white,black,blue.
|
||
properties.setProperty("kaptcha.image.width", "125"); // 图片宽
|
||
properties.setProperty("kaptcha.image.height", "45"); // 图片高
|
||
properties.setProperty("kaptcha.textproducer.font.size", "35"); // 字体大小
|
||
properties.setProperty("kaptcha.textproducer.char.length", "4"); // 验证码长度
|
||
properties.setProperty("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑"); // 字体
|
||
properties.setProperty("kaptcha.noise.impl", "com.google.code.kaptcha.impl.NoNoise"); // 去除干扰线
|
||
Config config = new Config(properties);
|
||
defaultKaptcha.setConfig(config);
|
||
return defaultKaptcha;
|
||
}
|
||
} |