package com.monkeylessey.framework.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;
|
|
/**
|
* @author xp
|
* @version 1.0
|
* @date 2022/4/21 0021
|
*/
|
@Configuration
|
public class CaptchaConfig {
|
|
@Bean
|
public DefaultKaptcha xpStartCaptcha() {
|
DefaultKaptcha captcha = new DefaultKaptcha();
|
Properties properties = new Properties();
|
properties.setProperty("kaptcha.border", "yes");
|
properties.setProperty("kaptcha.border.color", "white");
|
properties.setProperty("kaptcha.textproducer.font.color", "black");
|
properties.setProperty("kaptcha.image.width", "110");
|
properties.setProperty("kaptcha.image.height", "40");
|
properties.setProperty("kaptcha.textproducer.font.size", "30");
|
properties.setProperty("kaptcha.session.key", "code");
|
properties.setProperty("kaptcha.textproducer.char.length", "4");
|
properties.setProperty("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
|
Config config = new Config(properties);
|
captcha.setConfig(config);
|
return captcha;
|
}
|
}
|