KaptchaConfig.java 854 B

123456789101112131415161718192021222324252627282930
  1. package com.ydtech.config;
  2. import com.google.code.kaptcha.impl.DefaultKaptcha;
  3. import com.google.code.kaptcha.util.Config;
  4. import org.springframework.context.annotation.Bean;
  5. import org.springframework.context.annotation.Configuration;
  6. import java.util.Properties;
  7. /**
  8. * 验证码配置
  9. *
  10. * @author Yasepix
  11. * @date Oct 29, 2018
  12. */
  13. @Configuration
  14. public class KaptchaConfig {
  15. @Bean
  16. public DefaultKaptcha producer() {
  17. Properties properties = new Properties();
  18. properties.put("kaptcha.border", "no");
  19. properties.put("kaptcha.textproducer.font.color", "black");
  20. properties.put("kaptcha.textproducer.char.space", "4");
  21. Config config = new Config(properties);
  22. DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
  23. defaultKaptcha.setConfig(config);
  24. return defaultKaptcha;
  25. }
  26. }