KaptchaConfig.java 896 B

1234567891011121314151617181920212223242526272829303132
  1. package io.renren.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 chenshun
  11. * @email sunlightcs@gmail.com
  12. * @date 2017-04-20 19:22
  13. */
  14. @Configuration
  15. public class KaptchaConfig {
  16. @Bean
  17. public DefaultKaptcha producer() {
  18. Properties properties = new Properties();
  19. properties.put("kaptcha.border", "no");
  20. properties.put("kaptcha.textproducer.font.color", "black");
  21. properties.put("kaptcha.textproducer.char.space", "5");
  22. Config config = new Config(properties);
  23. DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
  24. defaultKaptcha.setConfig(config);
  25. return defaultKaptcha;
  26. }
  27. }