28 lines
902 B
Java
28 lines
902 B
Java
package cn.van.business.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;
|
|
|
|
@Configuration
|
|
public class KaptchaConfig {
|
|
|
|
@Bean
|
|
public DefaultKaptcha kaptchaProducer() {
|
|
DefaultKaptcha kaptcha = new DefaultKaptcha();
|
|
Properties properties = new Properties();
|
|
|
|
// 设置验证码参数
|
|
properties.setProperty("kaptcha.image.width", "150");
|
|
properties.setProperty("kaptcha.image.height", "50");
|
|
properties.setProperty("kaptcha.textproducer.char.string", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
|
properties.setProperty("kaptcha.textproducer.char.length", "4");
|
|
|
|
kaptcha.setConfig(new Config(properties));
|
|
return kaptcha;
|
|
}
|
|
}
|