首页>代码>springboot整合vue实现进销存管理系统>/jxc_project-master/src/main/java/com/cdy/jxc_project/config/CaptchaConfig.java
package com.cdy.jxc_project.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 AWEI
 * @version 1.0
 * @description: 验证码配置类
 * @date 2022/3/14 11:54
 */
@Configuration
public class CaptchaConfig {
    @Bean
    public DefaultKaptcha defaultKaptcha() {
        //验证码生成器
        DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
        //配置
        Properties properties = new Properties();
        //是否有边框
        properties.setProperty("kaptcha.border", "yes");
        //设置边框颜色
        properties.setProperty("kaptcha.border.color", "105,179,90");
        //边框粗细度,默认为1
        // properties.setProperty("kaptcha.border.thickness","1");
        //验证码
        properties.setProperty("kaptcha.session.key", "code");
        //验证码文本字符颜色 默认为黑色
        properties.setProperty("kaptcha.textproducer.font.color", "red");
        //设置字体样式
        properties.setProperty("kaptcha.textproducer.font.names", "楷体");
        //字体大小,默认40
        properties.setProperty("kaptcha.textproducer.font.size", "40");
        //验证码文本字符内容范围 默认为abced2345678gfynmnpwx
        // properties.setProperty("kaptcha.textproducer.char.string", "");
        //字符长度,默认为5
        properties.setProperty("kaptcha.textproducer.char.length", "4");
        //字符间距 默认为2
        properties.setProperty("kaptcha.textproducer.char.space", "4");
        //验证码图片宽度 默认为200
        properties.setProperty("kaptcha.image.width", "100");
        //验证码图片高度 默认为40
        properties.setProperty("kaptcha.image.height", "40");
        Config config = new Config(properties);
        defaultKaptcha.setConfig(config);
        return defaultKaptcha;
    }

}
最近下载更多
陈小灏  LV18 2月22日
liuyutong  LV3 2023年10月11日
小妹妹  LV7 2023年10月10日
笛卡尔积  LV6 2023年9月25日
yiy12345  LV2 2023年9月21日
guoyan  LV12 2023年9月15日
最近浏览更多
哪里的完整版  LV8 2月27日
docnnxxy688 2月26日
暂无贡献等级
andy_伟  LV6 2月25日
陈小灏  LV18 2月22日
zhao44413 2月21日
暂无贡献等级
weishenme1993  LV9 1月1日
微信网友_6955249237250048  LV5 2024年12月28日
随手一个用户名  LV1 2023年10月14日
liuyutong  LV3 2023年10月11日
wwfl02  LV3 2023年10月10日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友