content: package com.www.config.captcha;
  
  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;
  
  /**
   * Created with IntelliJ IDEA 2021.
   *
   * @Author: Mr Qin
   * @Date: 2024/03/24/22:38
   * @Description:
   */
  @Configuration
  public class KaptchaConfig {
  
      @Bean
      DefaultKaptcha producer() {
          Properties properties = new Properties();
          // 设置边界
          properties.put("kaptcha.border", "no");
          // 设置字体颜色为：黑色
          properties.put("kaptcha.textproducer.font.color", "black");
          // 文字间隔
          properties.put("kaptcha.textproducer.char.space", "4");
          // 设置高度
          properties.put("kaptcha.image.height", "40");
          // 设置宽度
          properties.put("kaptcha.image.width", "120");
          // 设置样式大小
          properties.put("kaptcha.textproducer.font.size", "30");
  
          Config config = new Config(properties);
          DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
          defaultKaptcha.setConfig(config);
  
          return defaultKaptcha;
      }
  }
  