diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2762fe6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +.project +.classpath +.settings +/.gradle/ +/bin/ +/build/ +.idea +/tmp/ +log.txt +.metadata/ diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..00b0045 --- /dev/null +++ b/build.gradle @@ -0,0 +1,56 @@ +buildscript { + repositories { + mavenCentral() + + } + dependencies { + classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.5.RELEASE") + } +} + +apply plugin: 'java' +apply plugin: 'eclipse' +apply plugin: 'application' +apply plugin: 'org.springframework.boot' +apply plugin: 'io.spring.dependency-management' + +group = 'com.taover.bazhuayun.analysis' +mainClassName = 'com.taover.bazhuayun.analysis.StartUp' +sourceCompatibility = 1.8 + +repositories { + maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/' } + jcenter() + maven{ url 'http://repository.sonatype.org/content/groups/public/' } + maven{ url 'https://repository.jboss.org/nexus/content/groups/public/' } + maven{ url 'http://nexus.taover.com:9001/repository/maven-releases/' } + +} + +dependencies { + compile( + "com.thoughtworks.xstream:xstream:1.4.12", + "org.springframework.boot:spring-boot-starter", + "org.springframework.boot:spring-boot-starter-web", + "org.springframework.boot:spring-boot-starter-jetty", + "org.springframework.boot:spring-boot-starter-data-jpa", + "org.springframework.boot:spring-boot-starter-mail", + + "mysql:mysql-connector-java", + + "com.hankcs:hanlp:portable-1.7.5", + + "com.aliyun.oss:aliyun-sdk-oss:2.0.7", + "com.alibaba:fastjson:1.2.72", + "com.alibaba:druid-spring-boot-starter:1.1.10", + + "com.xuxueli:xxl-job-core:2.1.0", + "com.taover:com-taover-repository:2.1.22", + "com.taover:com-taover-easyexcel:2.2.14", + "com.taover:com-taover-util:1.1.112", + "cn.hutool:hutool-all:5.2.4", + "com.taover:com-taover-codegenerate:1.2.11", + "com.auth0:java-jwt:3.4.0", + "io.jsonwebtoken:jjwt:0.6.0" + ) +} diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..048603d --- /dev/null +++ b/settings.gradle @@ -0,0 +1,10 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * The settings file is used to specify which projects to include in your build. + * + * Detailed information about configuring a multi-project build in Gradle can be found + * in the user guide at https://docs.gradle.org/4.5.1/userguide/multi_project_builds.html + */ + +rootProject.name = '8zyun-data-analysis' diff --git a/src/com/taover/bazhuayun/analysis/script/goodscollect/GoodsDataFileParser.java b/src/com/taover/bazhuayun/analysis/script/goodscollect/GoodsDataFileParser.java new file mode 100644 index 0000000..bec9c48 --- /dev/null +++ b/src/com/taover/bazhuayun/analysis/script/goodscollect/GoodsDataFileParser.java @@ -0,0 +1,68 @@ +package com.taover.bazhuayun.analysis.script.goodscollect; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import com.taover.bazhuayun.analysis.util.ExcelUtil; + +public class GoodsDataFileParser { + private String fileNameIgnorePreffix; + private StringBuffer logStrBuffer = new StringBuffer(); + private Set rowSet = new HashSet(); + + private String[] goodsNamePatternArr; + private String[] goodsSkuNameParrternArr; + private GroupInfoExcelData groupInfoData; + + public GoodsDataFileParser(String[] goodsNamePatternArr, String[] goodsSkuNameParrternArr, GroupInfoExcelData groupInfoData) { + this.goodsNamePatternArr = goodsNamePatternArr; + this.goodsSkuNameParrternArr = goodsSkuNameParrternArr; + this.groupInfoData = groupInfoData; + } + + public void setFileNameIgnorePreffix(String preffix) { + this.fileNameIgnorePreffix = preffix; + } + + public void parse(GroupInfoExcelData groupInfoData, File[] listFiles) throws Exception { + for(int i=0; i> data = ExcelUtil.readExcelSheet(item, false); + if(data.isEmpty()) { + continue; + } + + //写入set + GoodsInfoExcelDataHeader header = new GoodsInfoExcelDataHeader(this.goodsNamePatternArr, this.goodsSkuNameParrternArr, data.get(0)); + for(int j=1; j getResult() { + List data = new ArrayList(); + Iterator rowIter = this.rowSet.iterator(); + while(rowIter.hasNext()) { + data.add(rowIter.next()); + } + Collections.sort(data); + return data; + } + + public String getLogString() { + return logStrBuffer.toString(); + } + +} diff --git a/src/com/taover/bazhuayun/analysis/script/goodscollect/GoodsInfoExcelDataHeader.java b/src/com/taover/bazhuayun/analysis/script/goodscollect/GoodsInfoExcelDataHeader.java new file mode 100644 index 0000000..2a27745 --- /dev/null +++ b/src/com/taover/bazhuayun/analysis/script/goodscollect/GoodsInfoExcelDataHeader.java @@ -0,0 +1,40 @@ +package com.taover.bazhuayun.analysis.script.goodscollect; + +import java.util.List; + +import com.taover.bazhuayun.analysis.util.StringTool; + +public class GoodsInfoExcelDataHeader { + private Integer goodsNameIndex; + private Integer goodsSkuNameIndex; + + public GoodsInfoExcelDataHeader(String[] goodsNamePattern, String[] goodsSkuNamePattern, List data) { + for(int i=0; i{ + private String originGoodsName; + private String commonGoodsName; + private String groupNickname; + private String originGoodsSkuName; + private String commonGoodsSkuName; + private String senderNickname; + + public GoodsInfoRow(GroupInfoExcelDataRow groupInfo, GoodsInfoExcelDataHeader header, List data) { + if(groupInfo != null) { + this.groupNickname = groupInfo.getGroupName(); + this.senderNickname = groupInfo.getSendNickname(); + }else { + this.groupNickname = ""; + this.senderNickname = ""; + } + this.originGoodsName = this.getEmptyStrWhenNull(data, header.getGoodsNameIndex()); + this.originGoodsSkuName = this.getEmptyStrWhenNull(data, header.getGoodsSkuNameIndex()); + } + + private String getEmptyStrWhenNull(List data, Integer goodsNameIndex) { + if(goodsNameIndex == null) { + return ""; + } + if(data.size() > goodsNameIndex) { + Object temp = data.get(goodsNameIndex); + if(temp == null) { + return ""; + }else { + return temp.toString(); + } + }else { + return ""; + } + } + + public String getOriginGoodsName() { + return originGoodsName; + } + public void setOriginGoodsName(String originGoodsName) { + this.originGoodsName = originGoodsName; + } + public String getCommonGoodsName() { + return commonGoodsName; + } + public void setCommonGoodsName(String commonGoodsName) { + this.commonGoodsName = commonGoodsName; + } + public String getGroupNickname() { + return groupNickname; + } + public void setGroupNickname(String groupName) { + this.groupNickname = groupName; + } + public String getOriginGoodsSkuName() { + return originGoodsSkuName; + } + public void setOriginGoodsSkuName(String originGoodsSkuName) { + this.originGoodsSkuName = originGoodsSkuName; + } + public String getCommonGoodsSkuName() { + return commonGoodsSkuName; + } + public void setCommonGooodsSkuName(String commonSkuName) { + this.commonGoodsSkuName = commonSkuName; + } + public String getSenderNickname() { + return senderNickname; + } + public void setSenderNickname(String senderNickname) { + this.senderNickname = senderNickname; + } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((groupNickname == null) ? 0 : groupNickname.hashCode()); + result = prime * result + ((originGoodsName == null) ? 0 : originGoodsName.hashCode()); + result = prime * result + ((originGoodsSkuName == null) ? 0 : originGoodsSkuName.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + GoodsInfoRow other = (GoodsInfoRow) obj; + if (groupNickname == null) { + if (other.groupNickname != null) + return false; + } else if (!groupNickname.equals(other.groupNickname)) + return false; + if (originGoodsName == null) { + if (other.originGoodsName != null) + return false; + } else if (!originGoodsName.equals(other.originGoodsName)) + return false; + if (originGoodsSkuName == null) { + if (other.originGoodsSkuName != null) + return false; + } else if (!originGoodsSkuName.equals(other.originGoodsSkuName)) + return false; + return true; + } + + @Override + public int compareTo(GoodsInfoRow o) { + if(o == null) { + return 1; + } + if(this.equals(o)) { + return 0; + }else { + return this.calcDistince(o); + } + } + + private int calcDistince(GoodsInfoRow o) { + int groupDistince; + if(this.groupNickname == null && o.groupNickname == null) { + groupDistince = 0; + }else if(this.groupNickname == null){ + groupDistince = 0 - o.groupNickname.hashCode(); + }else if(o.groupNickname == null) { + groupDistince = this.groupNickname.hashCode(); + }else { + groupDistince = this.groupNickname.hashCode()-o.groupNickname.hashCode(); + } + int goodsNameDistince; + if(this.originGoodsName == null && o.originGoodsName == null) { + goodsNameDistince = 0; + }else if(this.originGoodsName == null){ + goodsNameDistince = 0 - o.originGoodsName.hashCode(); + }else if(o.originGoodsName == null) { + goodsNameDistince = this.originGoodsName.hashCode(); + }else { + goodsNameDistince = this.originGoodsName.hashCode()-o.originGoodsName.hashCode(); + } + int goodsSkuNameDistince; + if(this.originGoodsSkuName == null && o.originGoodsSkuName == null) { + goodsSkuNameDistince = 0; + }else if(this.originGoodsSkuName == null){ + goodsSkuNameDistince = 0 - o.originGoodsSkuName.hashCode(); + }else if(o.originGoodsSkuName == null) { + goodsSkuNameDistince = this.originGoodsSkuName.hashCode(); + }else { + goodsSkuNameDistince = this.originGoodsSkuName.hashCode()-o.originGoodsSkuName.hashCode(); + } + + return (int)(1.0*groupDistince/Integer.MAX_VALUE*1000)+(int)(1.0*goodsNameDistince/Integer.MAX_VALUE*100)+(int)(1.0*goodsSkuNameDistince/Integer.MAX_VALUE*10); + } +} diff --git a/src/com/taover/bazhuayun/analysis/script/goodscollect/GroupInfoExcelData.java b/src/com/taover/bazhuayun/analysis/script/goodscollect/GroupInfoExcelData.java new file mode 100644 index 0000000..887a131 --- /dev/null +++ b/src/com/taover/bazhuayun/analysis/script/goodscollect/GroupInfoExcelData.java @@ -0,0 +1,40 @@ +package com.taover.bazhuayun.analysis.script.goodscollect; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import com.taover.bazhuayun.analysis.util.ExcelUtil; + +public class GroupInfoExcelData { + private GroupInfoExcelDataHeader header; + private List rowList = new ArrayList(); + + public void load(String groupInfoFilePath) throws Exception { + if(groupInfoFilePath == null) { + throw new Exception("groupInfoFilePath is null"); + } + File groupInfoFile = new File(groupInfoFilePath); + if(!groupInfoFile.exists()) { + throw new Exception("groupinfofile not exists"); + } + + List> data = ExcelUtil.readExcelSheet(groupInfoFile, false); + if(data.size() > 0) { + header = new GroupInfoExcelDataHeader(data.get(0)); + } + for(int i=1; i data) { + for(int i=0; i data) { + if(header.getFielPathIndex() != null && data.size() > header.getFielPathIndex()) { + this.filePath = data.get(header.getFielPathIndex()) == null ? "" : data.get(header.getFielPathIndex()).toString(); + } + if(header.getRoowWxidIndex() != null && data.size() > header.getRoowWxidIndex()) { + this.roowWxid = data.get(header.getRoowWxidIndex()) == null ? "" : data.get(header.getRoowWxidIndex()).toString(); + } + if(header.getGroupNameIndex() != null && data.size() > header.getGroupNameIndex()) { + this.groupName = data.get(header.getGroupNameIndex()) == null ? "" : data.get(header.getGroupNameIndex()).toString(); + } + if(header.getSenderNicknameIndex() != null && data.size() > header.getSenderNicknameIndex()) { + this.sendNickname = data.get(header.getSenderNicknameIndex()) == null ? "" : data.get(header.getSenderNicknameIndex()).toString(); + } + if(this.filePath == null) { + this.filePath = ""; + } + if(this.roowWxid == null) { + this.roowWxid = ""; + } + if(this.groupName == null) { + this.groupName = ""; + } + if(this.sendNickname == null) { + this.sendNickname = ""; + } + } + + + public String getSendNickname() { + return sendNickname; + } + + + public void setSendNickname(String sendNickname) { + this.sendNickname = sendNickname; + } + + + public String getGroupName() { + return groupName; + } + public void setGroupName(String groupName) { + this.groupName = groupName; + } + public String getRoowWxid() { + return roowWxid; + } + public void setRoowWxid(String roowWxid) { + this.roowWxid = roowWxid; + } + public String getFilePath() { + return filePath; + } + public void setFilePath(String filePath) { + this.filePath = filePath; + } +} diff --git a/src/com/taover/bazhuayun/analysis/script/goodscollect/Main.java b/src/com/taover/bazhuayun/analysis/script/goodscollect/Main.java new file mode 100644 index 0000000..f2b4be6 --- /dev/null +++ b/src/com/taover/bazhuayun/analysis/script/goodscollect/Main.java @@ -0,0 +1,73 @@ +package com.taover.bazhuayun.analysis.script.goodscollect; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.poi.excel.ExcelUtil; + +public class Main { + public static void main(String[] args) { + try { + analysisGoodsName(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public static void analysisGoodsName() throws Exception { + String[] goodsNamePatternArr = new String[]{"商品名称","商品标题","货品名称","商品名称","商品信息","品名","商品型号","商品名","商品简称"}; + String[] goodsSkuNameParrternArr = new String[]{"商品规格名","规格","商品规格","规格名称","商品型号"}; + String groupInfoFilePath = "C:\\Users\\86136\\Desktop\\悟空家数据分析\\groupinfo.xls"; + String goodsDataFileDirPath = "C:\\Users\\86136\\Desktop\\悟空家数据分析\\data"; + String logFilePath = "C:\\Users\\86136\\Desktop\\悟空家数据分析\\dealinfo.log"; + String resultDataFilePath = "C:\\Users\\86136\\Desktop\\悟空家数据分析\\result.xls"; + + //加载基础数据,文件来源 + GroupInfoExcelData groupInfoData = new GroupInfoExcelData(); + groupInfoData.load(groupInfoFilePath); + + //读取文件列表,交由解析器处理 + GoodsDataFileParser parser = new GoodsDataFileParser(goodsNamePatternArr, goodsSkuNameParrternArr, groupInfoData); + parser.setFileNameIgnorePreffix("【异常物流信息】-"); + parser.parse(groupInfoData, new File(goodsDataFileDirPath).listFiles()); + + //结果写入结果文件 + ExcelUtil.getWriter(new File(resultDataFilePath)).write(transListBeanTo2List(parser.getResult())).flush(); + + //执行信息写入日志文件 + FileUtil.writeString(parser.getLogString(), logFilePath, CharsetUtil.CHARSET_UTF_8); + } + + private static List> transListBeanTo2List(List result) { + List> data = new ArrayList>(); + + //加入HEADER + List header = new ArrayList(); + header.add("原表名称"); + header.add("商品名称"); + header.add("原表规格"); + header.add("自选规格"); + header.add("仓库群名称"); + header.add("发文件的人"); + data.add(header); + + //加入BODY + for(int i=1; i item = new ArrayList(); + item.add(row.getOriginGoodsName()); + item.add(row.getCommonGoodsName()); + item.add(row.getOriginGoodsSkuName()); + item.add(row.getCommonGoodsSkuName()); + item.add(row.getGroupNickname()); + item.add(row.getSenderNickname()); + data.add(item); + } + + return data; + } +} diff --git a/src/com/taover/bazhuayun/analysis/util/ExcelUtil.java b/src/com/taover/bazhuayun/analysis/util/ExcelUtil.java new file mode 100644 index 0000000..971787b --- /dev/null +++ b/src/com/taover/bazhuayun/analysis/util/ExcelUtil.java @@ -0,0 +1,146 @@ +package com.taover.bazhuayun.analysis.util; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import com.taover.easyexcel.EasyExcel; + +import cn.hutool.core.text.csv.CsvRow; +import cn.hutool.core.text.csv.CsvUtil; +import cn.hutool.core.util.CharsetUtil; + +public class ExcelUtil { + private final static String CSV =".csv"; //csv + + private static boolean endWithCsv(String fileName) { + int dotIndex = fileName.lastIndexOf("."); + if(dotIndex < 0) { + return false; + } + String filteTypeLower = fileName.substring(dotIndex).trim().toLowerCase(); + if(CSV.equals(filteTypeLower)){ + return true; + } + return false; + } + + private static void checkFile(File dataFile) throws Exception{ + if(dataFile == null) { + throw new Exception("未传入文件引用"); + } + if(!dataFile.exists()) { + throw new Exception("文件不存在["+dataFile.getAbsolutePath()+"]"); + } + } + + private static List> transCsvRowToList(List rowData){ + List> data = new ArrayList>(); + if(rowData == null) { + return data; + } + for(CsvRow item: rowData) { + List itemData = new ArrayList(); + for(String cell: item.getRawList()) { + itemData.add(cell); + } + data.add(itemData); + } + return data; + } + + public static List> readExcelSheetAllForList(File dataFile, boolean readHiddenRow) throws Exception{ + checkFile(dataFile); + if(endWithCsv(dataFile.getName())) { + return transCsvRowToList(CsvUtil.getReader().read(dataFile, CharsetUtil.CHARSET_GBK).getRows()); + }else { + return transListMapTo2List(EasyExcel.read(dataFile).readHiddenRow(readHiddenRow).headRowNumber(0).doReadAllSync()); + } + } + + public static Map>> readExcelSheetAllForMap(File dataFile, boolean readHiddenRow) throws Exception{ + checkFile(dataFile); + if(endWithCsv(dataFile.getName())) { + return Collections.singletonMap("0", transCsvRowToList(CsvUtil.getReader().read(dataFile, CharsetUtil.CHARSET_GBK).getRows())); + }else { + return transMapListMapToMap2List(EasyExcel.read(dataFile).readHiddenRow(readHiddenRow).headRowNumber(0).doReadAllSyncForMap()); + } + } + + private static Map>> transMapListMapToMap2List(Map>> doReadAllSyncForMap) { + Map>> data = new HashMap>>(); + if(doReadAllSyncForMap == null) { + return data; + } + for(Entry>> item: doReadAllSyncForMap.entrySet()) { + List> itemData = new ArrayList>(); + for(Map cellData: item.getValue()) { + itemData.add(transMapToList(cellData)); + } + data.put(item.getKey().toString(), itemData); + } + return data; + } + + private static List> transListMapTo2List(List listMapData) { + List> data = new ArrayList>(); + if(listMapData == null) { + return data; + } + for(Object item: listMapData) { + data.add(transMapToList((Map) item)); + } + return data; + } + + private static List transMapToList(Map cellData) { + List data = new ArrayList((int)(cellData.size()*1.5)); + if(cellData == null || cellData.isEmpty()) { + return data; + } + + //获取最大索引 + int maxIndex = 0; + for(Entry item: cellData.entrySet()) { + if(item.getKey() > maxIndex && item.getValue()!=null && !"".equals(item.getValue())) { + maxIndex = item.getKey(); + } + } + + //设置元素并填入空串 + fillBlankToList(data, maxIndex+1); + + //置入元素 + int dataSize = data.size(); + for(Entry item: cellData.entrySet()) { + if(item.getKey() >= dataSize) { + continue; + } + if(item.getValue() == null) { + data.set(item.getKey(), ""); + }else { + data.set(item.getKey(), item.getValue()); + } + } + return data; + } + + private static void fillBlankToList(List data, int blankNumber) { + for(int i=0; i> readExcelSheet(File dataFile, boolean readHiddenRow) throws Exception{ + checkFile(dataFile); + if(endWithCsv(dataFile.getName())) { + return transCsvRowToList(CsvUtil.getReader().read(dataFile, CharsetUtil.CHARSET_GBK).getRows()); + }else { + return transListMapTo2List(EasyExcel.read(dataFile).readHiddenRow(readHiddenRow).headRowNumber(0).doReadSelectedSync()); + } + } +} diff --git a/src/com/taover/bazhuayun/analysis/util/StringTool.java b/src/com/taover/bazhuayun/analysis/util/StringTool.java new file mode 100644 index 0000000..c2e979b --- /dev/null +++ b/src/com/taover/bazhuayun/analysis/util/StringTool.java @@ -0,0 +1,193 @@ +package com.taover.bazhuayun.analysis.util; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.apache.commons.lang.StringUtils; + +import com.taover.util.UtilString; + + +public class StringTool { + public static String sortSplitStr(String cutTime, String splitStr, boolean isRemoveSame) { + if(cutTime == null || cutTime.isEmpty()) { + return cutTime; + } + String[] cutTimeArr = cutTime.split(splitStr); + List data = new ArrayList(cutTimeArr.length); + for(String item: cutTimeArr) { + int insertIndex = -1; + boolean isSame = false; + for(int i=0; i= 0){ + data.add(insertIndex, item); + } + } + return StringUtils.join(data, ","); + } + + public static String getOrTruncStr(String data, int allowLen) { + if(data == null) { + return ""; + } + byte[] dataByte = data.getBytes(); + if(dataByte.length > allowLen) { + return new String(dataByte, 0, allowLen); + }else { + return data; + } + } + + public static List splitByStringArr(String source, String[] patterns) { + List result = new ArrayList(); + if(source == null) { + return result; + } + if(patterns == null || patterns.length == 0) { + result.add(source); + return result; + } + String patternStr = StringUtils.join(patterns); + int subSourceStartIndex = 0; + for(int i=0; i subSourceStartIndex) { + result.add(source.substring(subSourceStartIndex, i)); + } + subSourceStartIndex = i+1; + } + } + if(subSourceStartIndex < source.length()) { + result.add(source.substring(subSourceStartIndex, source.length())); + } + return result; + } + + public static List removeSuffixSplitOrder(List data) { + List result = new ArrayList(); + if(data == null || data.isEmpty()) { + return result; + } + for(String item: data) { + item = item.trim(); + if(item.contains("-") && item.startsWith("W20")) { + String tempSubStr = item.substring(0, item.indexOf("-")); + if(StringUtils.isNotBlank(tempSubStr)) { + result.add(tempSubStr.trim()); + } + }else { + result.add(item); + } + } + return result; + } + + public static void trimObject(Object targetObj) { + Field[] tField = targetObj.getClass().getDeclaredFields(); + for(int i=0; i replaceAll(List data, String pattern, String target){ + List result = new ArrayList(); + if(data == null || data.isEmpty()) { + return result; + } + for(String item: data) { + result.add(item.replaceAll(pattern, target)); + } + return result; + } + + public static int getStartWithStringIndex(String pattern, String compares[]){ + //参数检验 + if(pattern==null || compares==null){ + return -1; + } + + //循环遍历compares + for(int i=0; i compares){ + //参数检验 + if(pattern==null || compares==null){ + return -1; + } + + //循环遍历compares + for(int i=0; i")); + System.out.println(replaceAll(Arrays.asList("asdf;asdfasdf"), "[;;]", " ")); + } +} + +class User{ + private String name = "2323"; + private int age = 1; + private List data; + public User(String name, int age, List data) { + super(); + this.name = name; + this.age = age; + this.data = data; + } + @Override + public String toString() { + return "User [name=" + name + ", age=" + age + ", data=" + data + "]"; + } +} diff --git a/src/com/taover/bazhuayun/analysis/web/StartUp.java b/src/com/taover/bazhuayun/analysis/web/StartUp.java new file mode 100644 index 0000000..27c4a86 --- /dev/null +++ b/src/com/taover/bazhuayun/analysis/web/StartUp.java @@ -0,0 +1,44 @@ +package com.taover.bazhuayun.analysis.web; + +import org.apache.catalina.connector.Connector; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; +import org.springframework.boot.web.servlet.server.ServletWebServerFactory; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.util.UrlPathHelper; + +@SpringBootApplication +@EnableAspectJAutoProxy(exposeProxy=true, proxyTargetClass=true) +public class StartUp implements WebMvcConfigurer { + public static ConfigurableApplicationContext context; + + public static void main(String[] args) { + System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true"); + StartUp.context = SpringApplication.run(StartUp.class, args); + } + + @Override + public void configurePathMatch(PathMatchConfigurer configurer) { + UrlPathHelper urlPathHelper = new UrlPathHelper(); + urlPathHelper.setUrlDecode(false); + configurer.setUrlPathHelper(urlPathHelper); + } + + @Bean + public ServletWebServerFactory servletContainer() { + TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); + tomcat.addAdditionalTomcatConnectors(createStandardConnector()); + return tomcat; + } + + private Connector createStandardConnector() { + Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); + connector.setPort(0); + return connector; + } +} \ No newline at end of file -- libgit2 0.21.2