From 4e912f383b7766af2db26fd13a12b5dea7a44a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=A2=A6=E6=8A=80=E6=9C=AF?= <596392912@qq.com> Date: Fri, 31 Jul 2020 16:03:54 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E4=BC=98=E5=8C=96=E9=85=8D?= =?UTF-8?q?=E7=BD=AE.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 21 ++++++++++ README.md | 18 ++------- .../captcha/CaptchaAutoConfiguration.java | 12 +++--- .../captcha/config/CaptchaEndpoint.java | 38 +++++++++---------- ...tional-spring-configuration-metadata.json} | 3 +- .../main/resources/META-INF/spring.factories | 2 - 6 files changed, 50 insertions(+), 44 deletions(-) create mode 100644 .editorconfig rename captcha-spring-boot-starter/src/main/resources/META-INF/{additional-configuration-metadata.json => additional-spring-configuration-metadata.json} (90%) delete mode 100644 captcha-spring-boot-starter/src/main/resources/META-INF/spring.factories diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8cfd370 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# http://editorconfig.org +root = true + +# 空格替代Tab缩进在各种编辑工具下效果一致 +[*] +indent_style = space +indent_size = 4 +charset = utf-8 +end_of_line = lf +trim_trailing_whitespace = true +insert_final_newline = true + +[*.java] +indent_style = tab + +[*.{json,yml}] +indent_size = 2 + +[*.md] +insert_final_newline = false +trim_trailing_whitespace = false diff --git a/README.md b/README.md index 57aec3c..38ebe9c 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ ### 3.1.gradle方式的引入 ```text dependencies { - compile 'com.github.whvcse:easy-captcha:1.6.2' + compile 'com.pig4cloud.plugin:easy-captcha:1.6.2' } ``` @@ -63,7 +63,7 @@ dependencies { ```xml - com.github.whvcse + com.pig4cloud.plugin easy-captcha 1.6.2 @@ -71,19 +71,7 @@ dependencies { ``` ### 3.3.jar包下载 -[easy-captcha-1.6.2.jar](https://gitee.com/whvse/EasyCaptcha/releases) - -maven导入jar包,在项目根目录创建`libs`文件夹,然后pom.xml添加如下: -``` - - com.github.whvcse - easy-captcha - 1.6.1 - ${basedir}/libs/easy-captcha-1.6.2.jar - -``` - ---- +[easy-captcha](https://repo1.maven.org/maven2/com/pig4cloud/plugin/easy-captcha) ## 4.使用方法 diff --git a/captcha-spring-boot-starter/src/main/java/com/pig4cloud/captcha/CaptchaAutoConfiguration.java b/captcha-spring-boot-starter/src/main/java/com/pig4cloud/captcha/CaptchaAutoConfiguration.java index b7778ac..4f0dfc5 100644 --- a/captcha-spring-boot-starter/src/main/java/com/pig4cloud/captcha/CaptchaAutoConfiguration.java +++ b/captcha-spring-boot-starter/src/main/java/com/pig4cloud/captcha/CaptchaAutoConfiguration.java @@ -13,14 +13,14 @@ *

* 验证码配置类 */ -@Configuration +@Configuration(proxyBeanMethods = false) @EnableConfigurationProperties(CaptchaProperties.class) public class CaptchaAutoConfiguration { - @Bean - @ConditionalOnWebApplication - public CaptchaEndpoint captchaEndpoint(CaptchaProperties properties) { - return new CaptchaEndpoint(properties); - } + @Bean + @ConditionalOnWebApplication + public CaptchaEndpoint captchaEndpoint(CaptchaProperties properties) { + return new CaptchaEndpoint(properties); + } } diff --git a/captcha-spring-boot-starter/src/main/java/com/pig4cloud/captcha/config/CaptchaEndpoint.java b/captcha-spring-boot-starter/src/main/java/com/pig4cloud/captcha/config/CaptchaEndpoint.java index 3b5dfea..c344242 100644 --- a/captcha-spring-boot-starter/src/main/java/com/pig4cloud/captcha/config/CaptchaEndpoint.java +++ b/captcha-spring-boot-starter/src/main/java/com/pig4cloud/captcha/config/CaptchaEndpoint.java @@ -18,25 +18,25 @@ @RequiredArgsConstructor public class CaptchaEndpoint { - private final CaptchaProperties properties; + private final CaptchaProperties properties; - /** - * 生成验证码 - * - * @param response 响应流 - */ - @SneakyThrows - @GetMapping("${captcha.create.path:/create}") - public void create(HttpServletResponse response) { - ArithmeticCaptcha captcha = new ArithmeticCaptcha(properties.getWidth(), properties.getHeight()); - String result = captcha.text(); - // 设置响应头 - response.setContentType(captcha.getContentType()); - response.setHeader("Pragma", "No-cache"); - response.setHeader("Cache-Control", "no-cache"); - response.setDateHeader("Expires", 0); - // 转换流信息写出 - captcha.out(response.getOutputStream()); - } + /** + * 生成验证码 + * + * @param response 响应流 + */ + @SneakyThrows + @GetMapping("${captcha.create.path:/create}") + public void create(HttpServletResponse response) { + ArithmeticCaptcha captcha = new ArithmeticCaptcha(properties.getWidth(), properties.getHeight()); + String result = captcha.text(); + // 设置响应头 + response.setContentType(captcha.getContentType()); + response.setHeader("Pragma", "No-cache"); + response.setHeader("Cache-Control", "no-cache"); + response.setDateHeader("Expires", 0); + // 转换流信息写出 + captcha.out(response.getOutputStream()); + } } diff --git a/captcha-spring-boot-starter/src/main/resources/META-INF/additional-configuration-metadata.json b/captcha-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json similarity index 90% rename from captcha-spring-boot-starter/src/main/resources/META-INF/additional-configuration-metadata.json rename to captcha-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 0eb078c..b287a55 100644 --- a/captcha-spring-boot-starter/src/main/resources/META-INF/additional-configuration-metadata.json +++ b/captcha-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -6,6 +6,5 @@ "description": "生成验证码请求路径", "defaultValue": "/create" } - ], - "hints": [] + ] } diff --git a/captcha-spring-boot-starter/src/main/resources/META-INF/spring.factories b/captcha-spring-boot-starter/src/main/resources/META-INF/spring.factories deleted file mode 100644 index cb85695..0000000 --- a/captcha-spring-boot-starter/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - com.pig4cloud.captcha.CaptchaAutoConfiguration