Files
Jarvis_java/src/main/java/cn/van/business/config/KaptchaConfig.java
雷欧(林平凡) 2e4128ab40 鉴权
2025-06-16 16:36:25 +08:00

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;
}
}