diff --git a/boot-service/src/main/java/com/xwbing/demo/Ademo.java b/boot-service/src/main/java/com/xwbing/demo/Ademo.java index 2505118..440cd02 100644 --- a/boot-service/src/main/java/com/xwbing/demo/Ademo.java +++ b/boot-service/src/main/java/com/xwbing/demo/Ademo.java @@ -8,13 +8,15 @@ package com.xwbing.demo; */ public class Ademo { public static void main(String[] args) { - qq: - for(int i=0;i<10;i++) { - for(int j=0;j<10;j++) { - if(j == 5) break qq; - } - } - System.out.println("11"=="11"); - System.out.println("11".equalsIgnoreCase(new String("11"))); + String a="aaaaa"; + String b="bbbbb"; + String aa = aa(a); + System.out.println(aa); + } + public static String aa(String aa){ + aa="aa"; + return aa; + } + } diff --git a/boot-service/src/main/java/com/xwbing/demo/LambdaDemo.java b/boot-service/src/main/java/com/xwbing/demo/LambdaDemo.java index 3128d65..f0299b3 100644 --- a/boot-service/src/main/java/com/xwbing/demo/LambdaDemo.java +++ b/boot-service/src/main/java/com/xwbing/demo/LambdaDemo.java @@ -50,11 +50,11 @@ public class LambdaDemo { System.out.println("重用filter:" + lists.stream().filter(gt.and(lt)).collect(Collectors.toList())); //删除 lists.removeIf(item -> item > 3);//根据条件删除,不用收集 - //聚合 + //聚合(最好给默认值,不然如果list为空时,聚合计算时会报错) System.out.println("reduce:" + lists.stream().reduce((o1, o2) -> o1 + o2).get());//聚合 System.out.println("reduce:" + lists.stream().reduce(0, (o1, o2) -> o1 + o2));//聚合(给定默认值) - System.out.println("ids:" + list.stream().reduce((sum, item) -> sum + "," + item).get());//常用//list(a,b,c)-->,a,b,c-->a,b,c - System.out.println("ids:" + list.stream().reduce("", (sum, item) -> sum + "," + item).substring(1)); + System.out.println("ids:" + list.stream().reduce((sum, item) -> sum + "," + item).get());//list(a,b,c)-->,a,b,c + System.out.println("ids:" + list.stream().reduce("", (sum, item) -> sum + "," + item).substring(1));//list(a,b,c)-->,a,b,c-->a,b,c String s = list.stream().reduce("", (sum, item) -> sum + "'" + item + "',");//list(a,b,c)-->'a','b','c',-->'a','b','c' System.out.println("id in:" + s.substring(0, s.lastIndexOf(","))); //join diff --git a/boot-service/src/main/java/com/xwbing/util/CommonDataUtil.java b/boot-service/src/main/java/com/xwbing/util/CommonDataUtil.java index 39990b5..ff51dfc 100644 --- a/boot-service/src/main/java/com/xwbing/util/CommonDataUtil.java +++ b/boot-service/src/main/java/com/xwbing/util/CommonDataUtil.java @@ -8,9 +8,9 @@ import java.util.Map; * 说明: 公共数据类 */ public class CommonDataUtil { - private static Map token = new HashMap(); + private static Map token=new HashMap<>(); - public CommonDataUtil() { + private CommonDataUtil() { } public static Object getToken(String key) { diff --git a/boot-service/src/main/java/com/xwbing/util/captcha/CaptchaServlet.java b/boot-service/src/main/java/com/xwbing/util/captcha/CaptchaServlet.java index ea30ee6..243b460 100644 --- a/boot-service/src/main/java/com/xwbing/util/captcha/CaptchaServlet.java +++ b/boot-service/src/main/java/com/xwbing/util/captcha/CaptchaServlet.java @@ -15,8 +15,7 @@ import java.io.OutputStream; /** * 说明: 创建验证码的servlet - * 创建日期: 2016年8月29日 上午10:59:27 - * 作者: xiangwbd + * 作者: xiangwb */ public class CaptchaServlet extends HttpServlet { private static final long serialVersionUID = -8687266469702749102L; diff --git a/boot-service/src/main/java/com/xwbing/util/captcha/CaptchaUtil.java b/boot-service/src/main/java/com/xwbing/util/captcha/CaptchaUtil.java index f3b9bf5..0dae529 100644 --- a/boot-service/src/main/java/com/xwbing/util/captcha/CaptchaUtil.java +++ b/boot-service/src/main/java/com/xwbing/util/captcha/CaptchaUtil.java @@ -9,7 +9,6 @@ import java.util.Random; /** * 说明:验证码工具类 - * 创建日期: 2016年8月29日 上午10:57:41 * 作者: xiangwb */ public class CaptchaUtil { @@ -19,10 +18,10 @@ public class CaptchaUtil { private static final String FONT_NAME = "Fixedsys"; private Random random = new Random(); private static final int FONT_SIZE = 18;// 字体大小 - private static final int width = 80;// 图片宽 - private static final int height = 25;// 图片高 - private static final int lineNum = 50;// 干扰线数量 - private static final int strNum = 4;// 随机产生字符数量 + private static final int WIDTH = 80;// 图片宽 + private static final int HEIGHT = 25;// 图片高 + private static final int LINE_NUM = 50;// 干扰线数量 + private static final int STR_NUM = 4;// 随机产生字符数量 /** @@ -30,23 +29,23 @@ public class CaptchaUtil { */ public BufferedImage genRandomCodeImage(StringBuffer randomCode) { // BufferedImage类是具有缓冲区的Image类 - BufferedImage image = new BufferedImage(width, height, + BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_BGR); // 获取Graphics对象,便于对图像进行各种绘制操作 Graphics g = image.getGraphics(); // 设置背景色 g.setColor(getRandColor(200, 250)); // 填充矩形面积 - g.fillRect(0, 0, width, height); + g.fillRect(0, 0, WIDTH, HEIGHT); // 设置干扰线的颜色 g.setColor(getRandColor(110, 120)); // 绘制干扰线 - for (int i = 0; i <= lineNum; i++) { + for (int i = 0; i <= LINE_NUM; i++) { drowLine(g); } // 绘制随机字符 - g.setFont(new Font(FONT_NAME, Font.ROMAN_BASELINE, FONT_SIZE)); - for (int i = 1; i <= strNum; i++) { + g.setFont(new Font(FONT_NAME, Font.PLAIN, FONT_SIZE)); + for (int i = 1; i <= STR_NUM; i++) { randomCode.append(drowString(g, i)); } g.dispose(); @@ -86,8 +85,8 @@ public class CaptchaUtil { * 绘制干扰线 */ private void drowLine(Graphics g) { - int x = random.nextInt(width); - int y = random.nextInt(height); + int x = random.nextInt(WIDTH); + int y = random.nextInt(HEIGHT); int x0 = random.nextInt(16); int y0 = random.nextInt(16); g.drawLine(x, y, x + x0, y + y0); @@ -104,7 +103,7 @@ public class CaptchaUtil { CaptchaUtil tool = new CaptchaUtil(); StringBuffer code = new StringBuffer(); BufferedImage image = tool.genRandomCodeImage(code); - System.out.println(">>> random code =: " + code); + System.out.println("random code : " + code); try { // 将内存中的图片通过流动形式输出到客户端 ImageIO.write(image, "JPEG", new FileOutputStream(new File( diff --git a/boot-web/pom.xml b/boot-web/pom.xml index acd7420..eeda06b 100644 --- a/boot-web/pom.xml +++ b/boot-web/pom.xml @@ -67,6 +67,12 @@ org.springframework.boot spring-boot-starter-aop + + + commons-fileupload + commons-fileupload + ${fileUpLoad.version} + boot-web diff --git a/boot-web/src/main/java/com/xwbing/configuration/ApplicationContextConfig.java b/boot-web/src/main/java/com/xwbing/configuration/ApplicationContextConfig.java index f765314..ff3bd3b 100644 --- a/boot-web/src/main/java/com/xwbing/configuration/ApplicationContextConfig.java +++ b/boot-web/src/main/java/com/xwbing/configuration/ApplicationContextConfig.java @@ -20,7 +20,7 @@ import javax.servlet.Filter; //@ImportResource("classpath:applicationContext.xml")//用来加载其他xml配置文件 public class ApplicationContextConfig { /** - * encoding编码问题(springBoot默认已经配置好) + * encoding编码问题(springBoot默认已经配置好,也可以在application.yml里配置) * * @return */ diff --git a/pom.xml b/pom.xml index f1fb911..edba6b7 100644 --- a/pom.xml +++ b/pom.xml @@ -37,8 +37,9 @@ 1.8 1.3.1 3.2.1 - 1.2.20 + 1.2.20 1.45 + 2.2 true 2.4.0 @@ -68,7 +69,7 @@ com.alibaba fastjson - ${fastjson.veersion} + ${fastjson.version} com.google.code.gson @@ -93,9 +94,9 @@ commons-beanutils - commons-fileupload - commons-fileupload - ${fileUpLoad.version} + commons-io + commons-io + ${commons-io.version}