diff --git a/README.md b/README.md index ba9cfcb..ae7616d 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,16 @@ 3.[Springboot集成RocketMQ](https://xiaour.github.io/2018/08/16/SpringbootRocketMQ/) +4.Webflux Spring异步编程,你将发现新大陆(代码已经部分上传,blog完善中...) -### 代码部分 +5.[利用EasyExcel,两行代码开发一个和API结果一致的生成Excel功能](https://github.com/xiaour/EasyExport#readme) + +## 代码部分 ⭐️ SpringBootDemo 本代码集成了SpringBoot+MyBatis+Redis+MySql。 -最新的部分经网友指正已经把冗余的代码去掉了,大家clone到本地后直接转成maven项目应该就可以运行了,项目中使用到的数据库表如下 +最新的部分经网友指正已经把冗余的代码去掉了,代码部分和配置文件部分都有相关的注释; +git clone 到本地后就可以运行了,项目中使用到的数据库表如下 ```sql -- ---------------------------- @@ -42,6 +46,9 @@ Springboot2.0继承了Kafka消息中间件 ⭐️ SpringBootRocketMqDemo Springboot2.0继承了RocketMQ4.3消息中间件 +⭐️ SpringWebfluxDemo +Webflux Spring异步编程。 + --------------------------------- 有兴趣的朋友可以关注一下最新开源的 diff --git a/SpringBootDemo/com.tony.spring.boot.iml b/SpringBootDemo/com.tony.spring.boot.iml deleted file mode 100644 index d5354ea..0000000 --- a/SpringBootDemo/com.tony.spring.boot.iml +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/SpringBootDemo/pom.xml b/SpringBootDemo/pom.xml index 230a45e..3280d80 100644 --- a/SpringBootDemo/pom.xml +++ b/SpringBootDemo/pom.xml @@ -4,14 +4,20 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.tony - com.xiaour.spring.boot - 1.0-SNAPSHOT + com.github.xiaour + springbootv1 + 0.0.1-SNAPSHOT + SpringBootDemo + Demo project for Spring Boot + jar + + org.springframework.boot spring-boot-starter-parent 1.5.2.RELEASE + @@ -93,13 +99,13 @@ com.alibaba fastjson - 1.2.31 + 1.2.83 commons-io commons-io - 2.5 + 2.7 @@ -116,7 +122,7 @@ org.apache.poi poi - 3.13 + 4.1.1 org.apache.poi diff --git a/SpringBootDemo/src/main/java/com/xiaour/spring/boot/Application.java b/SpringBootDemo/src/main/java/com/xiaour/spring/boot/Application.java index db70642..ba66900 100644 --- a/SpringBootDemo/src/main/java/com/xiaour/spring/boot/Application.java +++ b/SpringBootDemo/src/main/java/com/xiaour/spring/boot/Application.java @@ -1,46 +1,45 @@ -package com.xiaour.spring.boot; - -import org.mybatis.spring.annotation.MapperScan; -import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; -import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; -import org.springframework.boot.web.servlet.ServletComponentScan; -import org.springframework.boot.web.support.SpringBootServletInitializer; - -/** - * - * @ClassName Application - * @author Zhang.Tao - * @Date 2017年4月27日 下午5:30:34 - * @version V2.0.0 - */ - -@SpringBootApplication(exclude = MybatisAutoConfiguration.class) -@ServletComponentScan -@EnableAutoConfiguration -@MapperScan("com.xiaour.spring.boot.mapper") -public class Application extends SpringBootServletInitializer implements EmbeddedServletContainerCustomizer { - - @Value("${server.port}") - private int port;//应用的端口 - /** - * 启动入口 - * @param args - */ - public static void main(String ... args){ - SpringApplication.run(Application.class, args); - } - - /** - * 自定义端口 - */ - @Override - public void customize(ConfigurableEmbeddedServletContainer container) { - container.setPort(port); - } - -} +package com.xiaour.spring.boot; + +import org.mybatis.spring.annotation.MapperScan; +import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; +import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; +import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.boot.web.support.SpringBootServletInitializer; + +/** + * + * @ClassName Application + * @author Zhang.Tao + * @Date 2017年4月27日 下午5:30:34 + * @version V2.0.0 + */ + +@SpringBootApplication(exclude = MybatisAutoConfiguration.class) +@ServletComponentScan +@MapperScan("com.xiaour.spring.boot.mapper") +public class Application extends SpringBootServletInitializer implements EmbeddedServletContainerCustomizer { + + @Value("${server.port}") + private int port;//应用的端口 + /** + * 启动入口 + * @param args + */ + public static void main(String ... args){ + SpringApplication.run(Application.class, args); + } + + /** + * 自定义端口 + */ + @Override + public void customize(ConfigurableEmbeddedServletContainer container) { + container.setPort(port); + } + +} diff --git a/SpringBootDemo/src/main/java/com/xiaour/spring/boot/config/MyBatisConfig.java b/SpringBootDemo/src/main/java/com/xiaour/spring/boot/config/MyBatisConfig.java new file mode 100644 index 0000000..5b1f78d --- /dev/null +++ b/SpringBootDemo/src/main/java/com/xiaour/spring/boot/config/MyBatisConfig.java @@ -0,0 +1,46 @@ +package com.xiaour.spring.boot.config; + +import com.alibaba.druid.pool.DruidDataSource; +import org.apache.ibatis.session.SqlSessionFactory; +import org.mybatis.spring.SqlSessionFactoryBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; + + +/** + * @Date: 2018-12-26 12:05 + * @version: v1.0 + * @Description: mybatis stater从某个版本后去掉了自动配置,需要用config配置 + */ +@Configuration +public class MyBatisConfig { + + @Autowired + private DataSourceProperties dataSourceProperties; + + + @Bean(name = "dataSource") + public DruidDataSource dataSource() { + DruidDataSource dataSource = new DruidDataSource(); + dataSource.setUrl(dataSourceProperties.getUrl()); + + dataSource.setDriverClassName(dataSourceProperties.getDriverClassName()); + dataSource.setUsername(dataSourceProperties.getUsername()); + dataSource.setPassword(dataSourceProperties.getPassword()); + + return dataSource; + + } + + @Bean + public SqlSessionFactory sqlSessionFactory() throws Exception { + SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); + sqlSessionFactoryBean.setDataSource(dataSource()); + sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver() + .getResources(("classpath*:mapper/*.xml"))); + return sqlSessionFactoryBean.getObject(); + } +} diff --git a/SpringBootDemo/src/main/java/com/xiaour/spring/boot/exception/DingTalkEncryptException.java b/SpringBootDemo/src/main/java/com/xiaour/spring/boot/exception/DingTalkEncryptException.java deleted file mode 100644 index f279b8e..0000000 --- a/SpringBootDemo/src/main/java/com/xiaour/spring/boot/exception/DingTalkEncryptException.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.xiaour.spring.boot.exception; - -import java.util.HashMap; -import java.util.Map; - -/** - * 钉钉开放平台加解密异常类 - */ -public class DingTalkEncryptException extends Exception { - /**成功**/ - public static final int SUCCESS = 0; - /**加密明文文本非法**/ - public final static int ENCRYPTION_PLAINTEXT_ILLEGAL = 900001; - /**加密时间戳参数非法**/ - public final static int ENCRYPTION_TIMESTAMP_ILLEGAL = 900002; - /**加密随机字符串参数非法**/ - public final static int ENCRYPTION_NONCE_ILLEGAL = 900003; - /**不合法的aeskey**/ - public final static int AES_KEY_ILLEGAL = 900004; - /**签名不匹配**/ - public final static int SIGNATURE_NOT_MATCH = 900005; - /**计算签名错误**/ - public final static int COMPUTE_SIGNATURE_ERROR = 900006; - /**计算加密文字错误**/ - public final static int COMPUTE_ENCRYPT_TEXT_ERROR = 900007; - /**计算解密文字错误**/ - public final static int COMPUTE_DECRYPT_TEXT_ERROR = 900008; - /**计算解密文字长度不匹配**/ - public final static int COMPUTE_DECRYPT_TEXT_LENGTH_ERROR = 900009; - /**计算解密文字corpid不匹配**/ - public final static int COMPUTE_DECRYPT_TEXT_CORPID_ERROR = 900010; - - private static Map msgMap = new HashMap(); - static{ - msgMap.put(SUCCESS,"成功"); - msgMap.put(ENCRYPTION_PLAINTEXT_ILLEGAL,"加密明文文本非法"); - msgMap.put(ENCRYPTION_TIMESTAMP_ILLEGAL,"加密时间戳参数非法"); - msgMap.put(ENCRYPTION_NONCE_ILLEGAL,"加密随机字符串参数非法"); - msgMap.put(SIGNATURE_NOT_MATCH,"签名不匹配"); - msgMap.put(COMPUTE_SIGNATURE_ERROR,"签名计算失败"); - msgMap.put(AES_KEY_ILLEGAL,"不合法的aes key"); - msgMap.put(COMPUTE_ENCRYPT_TEXT_ERROR,"计算加密文字错误"); - msgMap.put(COMPUTE_DECRYPT_TEXT_ERROR,"计算解密文字错误"); - msgMap.put(COMPUTE_DECRYPT_TEXT_LENGTH_ERROR,"计算解密文字长度不匹配"); - msgMap.put(COMPUTE_DECRYPT_TEXT_CORPID_ERROR,"计算解密文字corpid或者suiteKey不匹配"); - } - - public Integer code; - public DingTalkEncryptException(Integer exceptionCode){ - super(msgMap.get(exceptionCode)); - this.code = exceptionCode; - } -} diff --git a/SpringBootDemo/src/main/java/com/xiaour/spring/boot/mapper/UserInfoMapper.java b/SpringBootDemo/src/main/java/com/xiaour/spring/boot/mapper/UserInfoMapper.java index 9850a58..50cb43f 100644 --- a/SpringBootDemo/src/main/java/com/xiaour/spring/boot/mapper/UserInfoMapper.java +++ b/SpringBootDemo/src/main/java/com/xiaour/spring/boot/mapper/UserInfoMapper.java @@ -1,9 +1,13 @@ -package com.xiaour.spring.boot.mapper; - -import com.xiaour.spring.boot.entity.UserInfo; - -public interface UserInfoMapper { - - UserInfo selectByPrimaryKey(Integer id); - +package com.xiaour.spring.boot.mapper; + +import com.xiaour.spring.boot.entity.UserInfo; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Component; + +@Component +@Mapper +public interface UserInfoMapper { + + UserInfo selectByPrimaryKey(Integer id); + } \ No newline at end of file diff --git a/SpringBootDemo/src/main/java/com/xiaour/spring/boot/utils/ExcelHander.java b/SpringBootDemo/src/main/java/com/xiaour/spring/boot/utils/ExcelHander.java deleted file mode 100644 index 28b41ed..0000000 --- a/SpringBootDemo/src/main/java/com/xiaour/spring/boot/utils/ExcelHander.java +++ /dev/null @@ -1,280 +0,0 @@ -package com.xiaour.spring.boot.utils; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.text.DecimalFormat; -import java.util.Date; -import java.util.HashMap; - -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.xssf.streaming.SXSSFSheet; -import org.apache.poi.xssf.streaming.SXSSFWorkbook; -import org.apache.poi.xssf.usermodel.XSSFRichTextString; -import org.apache.poi.xssf.usermodel.XSSFSheet; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; - - -public class ExcelHander { - /** - * 取得指定单元格行和列 - * @param keyMap 所有单元格行、列集合 - * @param key 单元格标识 - * @return 0:列 1:行(列表型数据不记行,即1无值) - */ - public static int[] getPos(HashMap keyMap, String key){ - int[] ret = new int[0]; - - String val = (String)keyMap.get(key); - - if(val == null || val.length() == 0) - return ret; - - String pos[] = val.split(","); - - if(pos.length == 1 || pos.length == 2){ - ret = new int[pos.length]; - for(int i0 = 0; i0 < pos.length; i0++){ - if(pos[i0] != null && pos[i0].trim().length() > 0){ - ret[i0] = Integer.parseInt(pos[i0].trim()); - } else { - ret[i0] = 0; - } - } - } - return ret; - } - - /** - * 取对应格子的值 - * @param sheet - * @param rowNo 行 - * @param cellNo 列 - * @return - * @throws IOException - */ - public static String getCellValue(Sheet sheet,int rowNo,int cellNo) { - String cellValue = null; - Row row = sheet.getRow(rowNo); - Cell cell = row.getCell(cellNo); - if (cell != null) { - if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) { - DecimalFormat df = new DecimalFormat("0"); - cellValue = getCutDotStr(df.format(cell.getNumericCellValue())); - } else if (cell.getCellType() == Cell.CELL_TYPE_STRING) { - cellValue = cell.getStringCellValue(); - } - if (cellValue != null) { - cellValue = cellValue.trim(); - } - } else { - cellValue = null; - } - return cellValue; - } - - /** - * 取整数 - * @param srcString - * @return - */ - private static String getCutDotStr(String srcString) { - String newString = ""; - if (srcString != null && srcString.endsWith(".0")) { - newString = srcString.substring(0,srcString.length()-2); - } else { - newString = srcString; - } - return newString; - } - - /** - * 读数据模板 - * @throws IOException - */ - public static HashMap[] getTemplateFile(String templateFileName) throws IOException { - FileInputStream fis = new FileInputStream(templateFileName); - - Workbook wbPartModule = null; - if(templateFileName.endsWith(".xlsx")){ - wbPartModule = new XSSFWorkbook(fis); - }else if(templateFileName.endsWith(".xls")){ - wbPartModule = new HSSFWorkbook(fis); - } - - int numOfSheet = wbPartModule.getNumberOfSheets(); - HashMap[] templateMap = new HashMap[numOfSheet]; - for(int i = 0; i < numOfSheet; i++){ - Sheet sheet = wbPartModule.getSheetAt(i); - templateMap[i] = new HashMap(); - readSheet(templateMap[i], sheet); - } - fis.close(); - return templateMap; - } - - /** - * @throws Exception - * - * @Title: getTemplateFile - * @Description: 获取对应的模板sheet - * @param @param templateFileName - * @param @param sheetName - * @param @return - * @param @throws IOException 设定文件 - * @return HashMap[] 返回类型 - * @throws - */ - public static void getTemplateSheet(SXSSFSheet targetSheet, SXSSFWorkbook targetWork,InputStream fis,String sheetName) throws Exception { - - XSSFWorkbook xs = new XSSFWorkbook(fis); - SXSSFWorkbook wbPartModule = new SXSSFWorkbook(xs); - XSSFSheet sheetTemp1 = null; - int numOfSheet1 = xs.getNumberOfSheets(); - //获取 - for(int i = 0; i < numOfSheet1; i++){ - XSSFSheet sheet = xs.getSheetAt(i); - if (sheet != null) { - String name = sheet.getSheetName(); - if (sheetName.equals(name)) { - sheetTemp1 = sheet; - } - } - } - - POIUtils.copySheet(targetSheet, sheetTemp1, targetWork, wbPartModule); - fis.close(); - } - /** - * 读模板数据的样式值置等信息 - * @param keyMap - * @param sheet - */ - private static void readSheet(HashMap keyMap, Sheet sheet){ - int firstRowNum = sheet.getFirstRowNum(); - int lastRowNum = sheet.getLastRowNum(); - System.out.println("当前sheet名称 -------------"+sheet.getSheetName()); - for (int j = firstRowNum; j <= lastRowNum; j++) { - Row rowIn = sheet.getRow(j); - if(rowIn == null) { - continue; - } - int firstCellNum = rowIn.getFirstCellNum(); - int lastCellNum = rowIn.getLastCellNum(); - for (int k = firstCellNum; k <= lastCellNum; k++) { -// Cell cellIn = rowIn.getCell((short) k); - Cell cellIn = rowIn.getCell(k); - if(cellIn == null) { - continue; - } - - int cellType = cellIn.getCellType(); - if(Cell.CELL_TYPE_STRING != cellType) { - continue; - } - String cellValue = cellIn.getStringCellValue(); - if(cellValue == null) { - continue; - } - cellValue = cellValue.trim(); - if(cellValue.length() > 2 && cellValue.substring(0,2).equals("<%")) { - String key = cellValue.substring(2, cellValue.length()); - String keyPos = Integer.toString(k)+","+Integer.toString(j); - keyMap.put(key, keyPos); - keyMap.put(key+"CellStyle", cellIn.getCellStyle()); - } else if(cellValue.length() > 3 && cellValue.substring(0,3).equals(" keyMap, String key,Workbook wb) { - CellStyle cellStyle = null; - - cellStyle = (CellStyle) keyMap.get(key+"CellStyle"); - //当字符超出时换行 - cellStyle.setWrapText(true); - CellStyle newStyle = wb.createCellStyle(); - newStyle.cloneStyleFrom(cellStyle); - return newStyle; - } - /** - * Excel单元格输出 - * @param sheet - * @param row 行 - * @param cell 列 - * @param value 值 - * @param cellStyle 样式 - */ - public static void setValue(Sheet sheet, int row, int cell, Object value, CellStyle cellStyle){ - Row rowIn = sheet.getRow(row); - if(rowIn == null) { - rowIn = sheet.createRow(row); - } - Cell cellIn = rowIn.getCell(cell); - if(cellIn == null) { - cellIn = rowIn.createCell(cell); - } - if(cellStyle != null) { - //修复产生多超过4000 cellStyle 异常 - //CellStyle newStyle = wb.createCellStyle(); - //newStyle.cloneStyleFrom(cellStyle); - cellIn.setCellStyle(cellStyle); - } - //对时间格式进行单独处理 - if(value==null){ - cellIn.setCellValue(""); - }else{ - if (isCellDateFormatted(cellStyle)) { - cellIn.setCellValue((Date) value); - } else { - cellIn.setCellValue(new XSSFRichTextString(value.toString())); - } - } - } - - /** - * 根据表格样式判断是否为日期格式 - * @param cellStyle - * @return - */ - public static boolean isCellDateFormatted(CellStyle cellStyle){ - if(cellStyle==null){ - return false; - } - int i = cellStyle.getDataFormat(); - String f = cellStyle.getDataFormatString(); - - return org.apache.poi.ss.usermodel.DateUtil.isADateFormat(i, f); - } - /** - * 适用于导出的数据Excel格式样式重复性较少 - * 不适用于循环方法中使用 - * @param wbModule - * @param sheet - * @param pos 模板文件信息 - * @param startCell 开始的行 - * @param value 要填充的数据 - * @param cellStyle 表格样式 - */ - public static void createCell(Workbook wbModule, Sheet sheet,HashMap pos, int startCell,Object value,String cellStyle){ - int[] excelPos = getPos(pos, cellStyle); - setValue(sheet, startCell, excelPos[0], value, getStyle(pos, cellStyle,wbModule)); - } - -} diff --git a/SpringBootDemo/src/main/java/com/xiaour/spring/boot/utils/JsonUtil.java b/SpringBootDemo/src/main/java/com/xiaour/spring/boot/utils/JsonUtil.java index d392db9..66be6e2 100644 --- a/SpringBootDemo/src/main/java/com/xiaour/spring/boot/utils/JsonUtil.java +++ b/SpringBootDemo/src/main/java/com/xiaour/spring/boot/utils/JsonUtil.java @@ -1,89 +1,83 @@ -package com.xiaour.spring.boot.utils; - -import com.google.gson.*; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class JsonUtil { - - private static Gson gson = null; - - static{ - gson = new Gson(); - } - - public static synchronized Gson newInstance(){ - if(gson == null){ - gson = new Gson(); - } - return gson; - } - - public static String getJsonString(Object obj){ - return gson.toJson(obj); - } - - public static T toBean(String json,Class clz){ - - return gson.fromJson(json, clz); - } - - public static Map readJson2MapObj(String json,Class clz){ - Map map = gson.fromJson(json, new TypeToken>(){}.getType()); - Map result = new HashMap<>(); - for(String key:map.keySet()){ - result.put(key,gson.fromJson(map.get(key),clz) ); - } - return result; - } - - public static T json2Obj(String json,Class clz){ - return gson.fromJson(json,clz); - } - - public static Map toMap(String json){ - Map map = gson.fromJson(json, new TypeToken>(){}.getType()); - return map; - } - - public static Map readJsonStrMap(String json) { - Map map = gson.fromJson(json, new TypeToken>(){}.getType()); - Map result = new HashMap<>(); - for(String key:map.keySet()){ - result.put(key,gson.fromJson(map.get(key),String.class) ); - } - return result; - } - - public static Map readJsonByteMap(String json) { - Map map = gson.fromJson(json, new TypeToken>(){}.getType()); - Map vmap = new HashMap<>(); - for(String key:map.keySet()){ - vmap.put(key.getBytes(),gson.fromJson(map.get(key),String.class).getBytes() ); - } - return vmap; - - } - - - public static List readJson2Array(String json, Class clz){ - JsonArray array = new JsonParser().parse(json).getAsJsonArray(); - List list = new ArrayList<>(); - for(final JsonElement elem : array){ - list.add(gson.fromJson(elem, (Type)clz)); - } - return list; - } - - - public static void main(String[] args) { - String json="{\"snapshots\":[{\"snapshot\":\"snapshot_129\",\"uuid\":\"kaM9ip2GQoCsT3wn38OcsQ\",\"version_id\":5040399,\"version\":\"5.4.3\",\"indices\":[\"metricbeat-2018.01.04\",\"metricbeat-2018.01.03\",\"metricbeat-2017.12.11\",\"metricbeat-2017.12.23\",\"metricbeat-2018.01.29\",\"metricbeat-2017.12.17\",\"metricbeat-2017.12.05\",\"metricbeat-2018.01.26\",\"metricbeat-2017.12.16\",\"metricbeat-2017.12.30\",\"metricbeat-2017.12.29\"],\"state\":\"SUCCESS\",\"duration_in_millis\":4310,\"failures\":[],\"shards\":{\"total\":321,\"failed\":0,\"successful\":321}}]}"; - - System.out.println(toMap(json)); - } +package com.xiaour.spring.boot.utils; + +import com.google.gson.*; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class JsonUtil { + + private static Gson gson = null; + + static{ + gson = new Gson(); + } + + public static synchronized Gson newInstance(){ + if(gson == null){ + gson = new Gson(); + } + return gson; + } + + public static String getJsonString(Object obj){ + return gson.toJson(obj); + } + + public static T toBean(String json,Class clz){ + + return gson.fromJson(json, clz); + } + + public static Map readJson2MapObj(String json,Class clz){ + Map map = gson.fromJson(json, new TypeToken>(){}.getType()); + Map result = new HashMap<>(); + for(String key:map.keySet()){ + result.put(key,gson.fromJson(map.get(key),clz) ); + } + return result; + } + + public static T json2Obj(String json,Class clz){ + return gson.fromJson(json,clz); + } + + public static Map toMap(String json){ + Map map = gson.fromJson(json, new TypeToken>(){}.getType()); + return map; + } + + public static Map readJsonStrMap(String json) { + Map map = gson.fromJson(json, new TypeToken>(){}.getType()); + Map result = new HashMap<>(); + for(String key:map.keySet()){ + result.put(key,gson.fromJson(map.get(key),String.class) ); + } + return result; + } + + public static Map readJsonByteMap(String json) { + Map map = gson.fromJson(json, new TypeToken>(){}.getType()); + Map vmap = new HashMap<>(); + for(String key:map.keySet()){ + vmap.put(key.getBytes(),gson.fromJson(map.get(key),String.class).getBytes() ); + } + return vmap; + + } + + + public static List readJson2Array(String json, Class clz){ + JsonArray array = new JsonParser().parse(json).getAsJsonArray(); + List list = new ArrayList<>(); + for(final JsonElement elem : array){ + list.add(gson.fromJson(elem, (Type)clz)); + } + return list; + } + } \ No newline at end of file diff --git a/SpringBootDemo/src/main/java/com/xiaour/spring/boot/utils/POIUtils.java b/SpringBootDemo/src/main/java/com/xiaour/spring/boot/utils/POIUtils.java deleted file mode 100644 index 83a90fb..0000000 --- a/SpringBootDemo/src/main/java/com/xiaour/spring/boot/utils/POIUtils.java +++ /dev/null @@ -1,228 +0,0 @@ -package com.xiaour.spring.boot.utils; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.poi.hssf.usermodel.HSSFCell; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.Comment; -import org.apache.poi.ss.usermodel.Drawing; -import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.xssf.streaming.SXSSFCell; -import org.apache.poi.xssf.streaming.SXSSFRow; -import org.apache.poi.xssf.streaming.SXSSFSheet; -import org.apache.poi.xssf.streaming.SXSSFWorkbook; -import org.apache.poi.xssf.usermodel.XSSFCell; -import org.apache.poi.xssf.usermodel.XSSFCellStyle; -import org.apache.poi.xssf.usermodel.XSSFClientAnchor; -import org.apache.poi.xssf.usermodel.XSSFRow; -import org.apache.poi.xssf.usermodel.XSSFSheet; - -/** - * -* @ClassName: POIUtils -* @Description: POIUtils工具类 -* - */ -public class POIUtils { - - /** - * 功能:拷贝sheet - * 实际调用 copySheet(targetSheet, sourceSheet, targetWork, sourceWork, true) - * @param targetSheet - * @param sourceSheet - * @param targetWork - * @param sourceWork - */ - public static void copySheet(SXSSFSheet targetSheet, XSSFSheet sourceSheet, - SXSSFWorkbook targetWork, SXSSFWorkbook sourceWork) throws Exception{ - if(targetSheet == null || sourceSheet == null || targetWork == null || sourceWork == null){ - throw new IllegalArgumentException("调用PoiUtil.copySheet()方法时,targetSheet、sourceSheet、targetWork、sourceWork都不能为空,故抛出该异常!"); - } - copySheet(targetSheet, sourceSheet, targetWork, sourceWork, true); - } - - /** - * 功能:拷贝sheet - * @param targetSheet - * @param sourceSheet - * @param targetWork - * @param sourceWork - * @param copyStyle boolean 是否拷贝样式 - */ - public static void copySheet(SXSSFSheet targetSheet, XSSFSheet sourceSheet, - SXSSFWorkbook targetWork, SXSSFWorkbook sourceWork, boolean copyStyle)throws Exception { - - if(targetSheet == null || sourceSheet == null || targetWork == null || sourceWork == null){ - throw new IllegalArgumentException("调用PoiUtil.copySheet()方法时,targetSheet、sourceSheet、targetWork、sourceWork都不能为空,故抛出该异常!"); - } - - //复制源表中的行 - int maxColumnNum = 0; - - Map styleMap = (copyStyle) ? new HashMap() : null; - - Drawing patriarch = targetSheet.createDrawingPatriarch(); //用于复制注释 - for (int i = sourceSheet.getFirstRowNum(); i <= sourceSheet.getLastRowNum(); i++) { - XSSFRow sourceRow = sourceSheet.getRow(i); - SXSSFRow targetRow = (SXSSFRow) targetSheet.createRow(i); - - if (sourceRow != null) { - copyRow(targetRow, sourceRow, - targetWork, sourceWork,patriarch, styleMap); - if (sourceRow.getLastCellNum() > maxColumnNum) { - - maxColumnNum = sourceRow.getLastCellNum(); - } - } - } - - //复制源表中的合并单元格 - mergerRegion(targetSheet, sourceSheet); - - //设置目标sheet的列宽 - if (maxColumnNum > 100) { - maxColumnNum = 100; - } - for (int i = 0; i <= maxColumnNum; i++) { - targetSheet.setColumnWidth(i, sourceSheet.getColumnWidth(i)); - } - } - - /** - * 功能:拷贝row - * @param targetRow - * @param sourceRow - * @param styleMap - * @param targetWork - * @param sourceWork - * @param targetPatriarch - */ - public static void copyRow(SXSSFRow targetRow, XSSFRow sourceRow, - SXSSFWorkbook targetWork, SXSSFWorkbook sourceWork,Drawing targetPatriarch, Map styleMap) throws Exception { - if(targetRow == null || sourceRow == null || targetWork == null || sourceWork == null || targetPatriarch == null){ - throw new IllegalArgumentException("调用PoiUtil.copyRow()方法时,targetRow、sourceRow、targetWork、sourceWork、targetPatriarch都不能为空,故抛出该异常!"); - } - - //设置行高 - targetRow.setHeight(sourceRow.getHeight()); - - for (int i = sourceRow.getFirstCellNum(); i <= sourceRow.getLastCellNum(); i++) { - XSSFCell sourceCell = sourceRow.getCell(i); - SXSSFCell targetCell = (SXSSFCell) targetRow.getCell(i); - - if (sourceCell != null) { - if (targetCell == null) { - targetCell = (SXSSFCell) targetRow.createCell(i); - } - - //拷贝单元格,包括内容和样式 - copyCell(targetCell, sourceCell, targetWork, sourceWork, styleMap); - - //拷贝单元格注释 - copyComment(targetCell,sourceCell,targetPatriarch); - } - } - } - - /** - * 功能:拷贝cell,依据styleMap是否为空判断是否拷贝单元格样式 - * @param targetCell 不能为空 - * @param sourceCell 不能为空 - * @param targetWork 不能为空 - * @param sourceWork 不能为空 - * @param styleMap 可以为空 - */ - public static void copyCell(SXSSFCell targetCell, XSSFCell sourceCell, SXSSFWorkbook targetWork, SXSSFWorkbook sourceWork,Map styleMap) { - if(targetCell == null || sourceCell == null || targetWork == null || sourceWork == null ){ - throw new IllegalArgumentException("调用PoiUtil.copyCell()方法时,targetCell、sourceCell、targetWork、sourceWork都不能为空,故抛出该异常!"); - } - - //处理单元格样式 - if(styleMap != null){ - if (targetWork == sourceWork) { - targetCell.setCellStyle(sourceCell.getCellStyle()); - } else { - String stHashCode = "" + sourceCell.getCellStyle().hashCode(); - CellStyle targetCellStyle = (XSSFCellStyle) styleMap - .get(stHashCode); - if (targetCellStyle == null) { - targetCellStyle = targetWork.createCellStyle(); - targetCellStyle.cloneStyleFrom(sourceCell.getCellStyle()); - styleMap.put(stHashCode, targetCellStyle); - } - - targetCell.setCellStyle(targetCellStyle); - } - } - - //处理单元格内容 - switch (sourceCell.getCellType()) { - case HSSFCell.CELL_TYPE_STRING: - targetCell.setCellValue(sourceCell.getRichStringCellValue()); - break; - case HSSFCell.CELL_TYPE_NUMERIC: - targetCell.setCellValue(sourceCell.getNumericCellValue()); - break; - case HSSFCell.CELL_TYPE_BLANK: - targetCell.setCellType(HSSFCell.CELL_TYPE_BLANK); - break; - case HSSFCell.CELL_TYPE_BOOLEAN: - targetCell.setCellValue(sourceCell.getBooleanCellValue()); - break; - case HSSFCell.CELL_TYPE_ERROR: - targetCell.setCellErrorValue(sourceCell.getErrorCellValue()); - break; - case HSSFCell.CELL_TYPE_FORMULA: - targetCell.setCellFormula(sourceCell.getCellFormula()); - break; - default: - break; - } - } - - /** - * 功能:拷贝comment - * @param targetCell - * @param sourceCell - * @param targetPatriarch - */ - public static void copyComment(SXSSFCell targetCell,XSSFCell sourceCell,Drawing targetPatriarch)throws Exception{ - if(targetCell == null || sourceCell == null || targetPatriarch == null){ - throw new IllegalArgumentException("调用PoiUtil.copyCommentr()方法时,targetCell、sourceCell、targetPatriarch都不能为空,故抛出该异常!"); - } - - //处理单元格注释 - Comment comment = sourceCell.getCellComment(); - if(comment != null){ - Comment newComment = targetPatriarch.createCellComment(new XSSFClientAnchor()); - newComment.setAuthor(comment.getAuthor()); - newComment.setColumn(comment.getColumn()); - newComment.setRow(comment.getRow()); - newComment.setString(comment.getString()); - newComment.setVisible(comment.isVisible()); - - targetCell.setCellComment(newComment); - } - } - - /** - * 功能:复制原有sheet的合并单元格到新创建的sheet - * - * @param sourceSheet - */ - public static void mergerRegion(SXSSFSheet targetSheet, XSSFSheet sourceSheet)throws Exception { - if(targetSheet == null || sourceSheet == null){ - throw new IllegalArgumentException("调用PoiUtil.mergerRegion()方法时,targetSheet或者sourceSheet不能为空,故抛出该异常!"); - } - - for (int i = 0; i < sourceSheet.getNumMergedRegions(); i++) { - CellRangeAddress oldRange = sourceSheet.getMergedRegion(i); - CellRangeAddress newRange = new CellRangeAddress( - oldRange.getFirstRow(), oldRange.getLastRow(), - oldRange.getFirstColumn(), oldRange.getLastColumn()); - targetSheet.addMergedRegion(newRange); - } - } - -} diff --git a/SpringBootDemo/src/main/resources/application.yml b/SpringBootDemo/src/main/resources/application.yml index b1fe622..167b873 100644 --- a/SpringBootDemo/src/main/resources/application.yml +++ b/SpringBootDemo/src/main/resources/application.yml @@ -1,52 +1,39 @@ -#服务启动端口 -server : - port : 8080 - -#数据库配置 -spring: - datasource: - name: test - url: jdbc:mysql://192.168.2.5:3335/test_data?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&allowMultiQueries=true&useSSL=false&zeroDateTimeBehavior=convertToNull - username: root - password: chifaner159 - # 使用druid数据源 - type: com.alibaba.druid.pool.DruidDataSource - driver-class-name: com.mysql.jdbc.Driver - filters: stat - maxActive: 20 - initialSize: 1 - maxWait: 60000 - minIdle: 1 - timeBetweenEvictionRunsMillis: 60000 - minEvictableIdleTimeMillis: 300000 - validationQuery: select 'x' - testWhileIdle: true - testOnBorrow: false - testOnReturn: false - poolPreparedStatements: true - maxOpenPreparedStatements: 20 - redis: - host: 192.168.2.5 - #redis密码,没有密码的可以用~表示 - password: ~ - port: 6381 - pool: - max-active: 100 - max-idle: 10 - max-wait: 100000 -mybatis: - type-aliases-package: com.xiaour.spring.boot.mapper - mapper-locations: classpath:mapper/*.xml - configLocation: classpath:mybatis-config.xml - -# 日志输出 -logging: - file: D:/boot.log - level: - com.ibatis:DEBUG - root:DEBUG - -task: - cron:0 0/5 * * * ? - - +#服务启动端口 +server : + port : 8080 + +#数据库配置 +spring: + datasource: + url: jdbc:mysql://127.0.0.1:9966/study?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&autoReconnect=true&useSSL=false&verifyServerCertificate=false + username: your.account + password: your.pass + # 使用druid数据源 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.jdbc.Driver + redis: + host: 127.0.0.1 + #redis密码,没有密码的可以用~表示 + password: ~ + port: 6379 + pool: + max-active: 100 + max-idle: 10 + max-wait: 100000 +# Mybatis mapper 映射路径配置 +mybatis: + type-aliases-package: com.xiaour.spring.boot.mapper + mapper-locations: classpath*:mapper/*.xml + configLocation: classpath:mybatis-config.xml + +# 日志输出 +logging: + file: D:/boot.log + level: + com.ibatis:DEBUG + root:DEBUG + +task: + cron:0 0/5 * * * ? + + diff --git a/SpringBootDemoV2/.mvn/wrapper/maven-wrapper.jar b/SpringBootDemoV2/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index 9cc84ea..0000000 Binary files a/SpringBootDemoV2/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/SpringBootDemoV2/.mvn/wrapper/maven-wrapper.properties b/SpringBootDemoV2/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 9dda3b6..0000000 --- a/SpringBootDemoV2/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1 +0,0 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip diff --git a/SpringBootDemoV2/pom.xml b/SpringBootDemoV2/pom.xml index 62a7b2a..9c0856a 100644 --- a/SpringBootDemoV2/pom.xml +++ b/SpringBootDemoV2/pom.xml @@ -3,18 +3,18 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - SpringBootDemoV2 - SpringBootDemoV2 + com.github.xiaour + springbootv2 0.0.1-SNAPSHOT - jar - SpringBootDemoV2 Demo project for Spring Boot V2 + jar + org.springframework.boot spring-boot-starter-parent - 2.0.0.RELEASE + 2.4.2 @@ -29,6 +29,7 @@ org.springframework.boot spring-boot-starter-data-redis + org.springframework.boot spring-boot-starter-web @@ -43,7 +44,7 @@ org.apache.zookeeper zookeeper - 3.4.11 + 3.7.2 @@ -56,7 +57,7 @@ com.google.code.gson gson - 2.8.2 + 2.8.9 @@ -65,15 +66,10 @@ 1.10 - - dom4j - dom4j - - junit junit - 4.12 + 4.13.1 diff --git a/SpringBootDemoV2/src/main/java/com/github/xiaour/Application.java b/SpringBootDemoV2/src/main/java/com/github/xiaour/Application.java index c1e862e..caf30a9 100644 --- a/SpringBootDemoV2/src/main/java/com/github/xiaour/Application.java +++ b/SpringBootDemoV2/src/main/java/com/github/xiaour/Application.java @@ -10,7 +10,8 @@ public class Application { public static void main(String[] args) { - SpringApplication.run(Application.class, args); + //SpringApplication.run(Application.class, args); + } diff --git a/SpringBootDemoV2/src/main/java/com/github/xiaour/controller/AuthNotify.java b/SpringBootDemoV2/src/main/java/com/github/xiaour/controller/AuthNotify.java deleted file mode 100644 index 11dfee9..0000000 --- a/SpringBootDemoV2/src/main/java/com/github/xiaour/controller/AuthNotify.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.github.xiaour.controller; - -import com.github.xiaour.constants.Api; -import com.github.xiaour.exception.OApiException; -import com.github.xiaour.utils.HttpHelper; -import com.github.xiaour.utils.JsonUtil; -import com.github.xiaour.utils.WXBizMsgCrypt; -import com.github.xiaour.utils.Xml2JsonUtil; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import jdk.nashorn.internal.parser.JSONParser; -import org.springframework.web.bind.annotation.*; - -import java.util.HashMap; -import java.util.Map; - -/** - * 授权事件接收 - * @Author: Xiaour - * @Description: - * @Date: 2018/3/12 下午5:27 - */ -@RestController -public class AuthNotify { - - - /** - * 这里以后肯定要维护到配置文件或缓存的 - * @param requestBody - * @return - */ - - private static String aesKey="4a5665bf9fbe0618b7154cc9d93342b6a7b2abcf4e8"; - - private static String token="ois3rd"; - - private static String appsecret="a38dd974a9e6490dfbf5b21cd38f9996"; - - private static String component_access_token=""; - - - @RequestMapping("auth_notify") - @PostMapping(produces = "application/xml; charset=UTF-8") - public String payNotify(@RequestBody String requestBody, @RequestParam("timestamp")String timestamp, @RequestParam("nonce")String nonce, - @RequestParam("msg_signature")String msgSignature){ - String appid=null; - Map data= new HashMap<>(); - data.put("timestamp",timestamp); - data.put("nonce",nonce); - data.put("msg_signature",msgSignature); - data.put("requestBody",requestBody); - - System.out.println(data); - - try { - JsonObject jsonData= Xml2JsonUtil.xml2Json(requestBody); - - appid=jsonData.get("AppId").getAsString(); - - WXBizMsgCrypt pc = new WXBizMsgCrypt(token, aesKey,appid); - - String decode=pc.decryptMsg(msgSignature,timestamp,nonce,jsonData.get("Encrypt").getAsString()); - - System.out.println(decode); - - JsonObject decodeJson=Xml2JsonUtil.xml2Json(decode); - - getComponentTtoken(appid,appsecret,decodeJson.get("ComponentVerifyTicket").getAsString()); - - getPreAuthCode(appid); - - } catch (Exception e) { - - e.printStackTrace(); - - } - return "success"; - } - - private String getPreAuthCode(String appid) { - String preAuthCode=null; - - Map postData=new HashMap<>(); - - postData.put("component_appid",appid); - try { - - String jsonStr= HttpHelper.postByRest(Api.create_preauthcode+component_access_token,String.class,null, JsonUtil.getJsonString(postData)); - Map jsonMap= JsonUtil.json2Obj(jsonStr,Map.class); - - preAuthCode=jsonMap.get("pre_auth_code").toString(); - - String guideUrl="https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid="+appid+"&pre_auth_code="+preAuthCode+"&redirect_uri=http://sp.chifaner.com/wx/callback/auth"; - - System.out.println(guideUrl); - - return preAuthCode; - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - private void getComponentTtoken(String appid, String appsecret, String componentVerifyTicket){ - - Map postData=new HashMap<>(); - - postData.put("component_appid",appid); - - postData.put("component_appsecret",appsecret); - - postData.put("component_verify_ticket",componentVerifyTicket); - - try { - - String jsonStr= HttpHelper.postByRest(Api.component_token,String.class,null, JsonUtil.getJsonString(postData)); - Map jsonMap= JsonUtil.json2Obj(jsonStr,Map.class); - component_access_token=jsonMap.get("component_access_token").toString(); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - public static void main(String[] args) { - String xml="" + "\n" + - "\n" + ""; - try { - JsonObject jsonData= Xml2JsonUtil.xml2Json(xml); - - WXBizMsgCrypt pc = null; - - pc = new WXBizMsgCrypt(token, aesKey,"wxa797588149020de4"); - - System.out.println(jsonData.get("Encrypt").getAsString()); - - String decode=pc.decryptMsg("d5b4bcef832c27f6f2804d0055cec64864c82a54","1520922592","941622427",jsonData.get("Encrypt").getAsString()); - - JsonObject decodeJson=Xml2JsonUtil.xml2Json(decode); - - System.out.println(decodeJson.get("ComponentVerifyTicket").getAsString()); - } catch (Exception e) { - e.printStackTrace(); - } - } - -} diff --git a/SpringBootDemoV2/src/main/java/com/github/xiaour/controller/WxCallback.java b/SpringBootDemoV2/src/main/java/com/github/xiaour/controller/WxCallback.java deleted file mode 100644 index 98085fa..0000000 --- a/SpringBootDemoV2/src/main/java/com/github/xiaour/controller/WxCallback.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.github.xiaour.controller; - -import com.github.xiaour.utils.Xml2JsonUtil; -import com.google.gson.JsonObject; -import org.dom4j.DocumentException; -import org.springframework.web.bind.annotation.*; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * 消息与事件接收 - * @Author: Xiaour - * @Description: - * @Date: 2018/3/12 下午5:25 - */ - -@RestController -public class WxCallback { - - @RequestMapping("callback/auth") - public String callbackAuth(String auth_code,Integer expires_in){ - System.out.println("auth_code:"+auth_code); - System.out.println("expires_in:"+expires_in); - return "success"; - } - - - @RequestMapping("callback/{appid}") - @PostMapping(produces = "application/xml; charset=UTF-8") - public String callbackMsg(@RequestBody String requestBody, @PathVariable String appid){ - System.out.println(appid); - System.out.println(requestBody); - try { - JsonObject jsonData= Xml2JsonUtil.xml2Json(requestBody); - System.out.println(jsonData); - } catch (DocumentException e) { - e.printStackTrace(); - } - return "success"; - } - - -} diff --git a/SpringBootDemoV3/.gitignore b/SpringBootDemoV3/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/SpringBootDemoV3/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/SpringBootDemoV3/pom.xml b/SpringBootDemoV3/pom.xml new file mode 100644 index 0000000..110db5f --- /dev/null +++ b/SpringBootDemoV3/pom.xml @@ -0,0 +1,64 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.2.3 + + + + com.github.xiaour + springbootv3 + 0.0.1-SNAPSHOT + SpringBootDemoV3 + Demo project for Spring Boot + jar + + + 17 + + + + + + org.springframework.boot + spring-boot-starter + + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.springframework.boot + spring-boot-starter-web + + + + io.github.xiaour + easy-export + 1.0.1-RELEASE + + + + com.alibaba + easyexcel + 2.2.3 + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/SpringBootDemoV3/src/main/java/com/xiaour/spring/boot/SpringBootDemoV3Application.java b/SpringBootDemoV3/src/main/java/com/xiaour/spring/boot/SpringBootDemoV3Application.java new file mode 100644 index 0000000..7b98f02 --- /dev/null +++ b/SpringBootDemoV3/src/main/java/com/xiaour/spring/boot/SpringBootDemoV3Application.java @@ -0,0 +1,15 @@ +package com.xiaour.spring.boot; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringBootDemoV3Application { + + public static void main(String[] args) { + SpringApplication.run(SpringBootDemoV3Application.class, args); + //System.out.println(Math.max(10,11)); + } + + +} diff --git a/SpringBootDemoV3/src/main/java/com/xiaour/spring/boot/controller/CatController.java b/SpringBootDemoV3/src/main/java/com/xiaour/spring/boot/controller/CatController.java new file mode 100644 index 0000000..d740815 --- /dev/null +++ b/SpringBootDemoV3/src/main/java/com/xiaour/spring/boot/controller/CatController.java @@ -0,0 +1,34 @@ +package com.xiaour.spring.boot.controller; + +import com.xiaour.spring.boot.entity.PageIndex; +import com.xiaour.spring.boot.entity.PageInfo; +import com.xiaour.spring.boot.service.CatService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/cat") +public class CatController { + + private CatService catService; + + @Autowired + public CatController(CatService catService) { + this.catService = catService; + } + + @GetMapping("list") + public PageInfo getCatList() { + PageIndex index = new PageIndex(); + index.setPageIndex(1); + index.setPageSize(30); + return catService.getCatList(index); + } + + + + + +} diff --git a/SpringBootDemoV3/src/main/java/com/xiaour/spring/boot/entity/Cat.java b/SpringBootDemoV3/src/main/java/com/xiaour/spring/boot/entity/Cat.java new file mode 100644 index 0000000..5aef16e --- /dev/null +++ b/SpringBootDemoV3/src/main/java/com/xiaour/spring/boot/entity/Cat.java @@ -0,0 +1,60 @@ +package com.xiaour.spring.boot.entity; + +import com.alibaba.excel.annotation.ExcelProperty; + +public class Cat { + + /** + * 宠物昵称 + */ + @ExcelProperty(value = "昵称") + private String nickName; + + /** + * 年龄 + */ + @ExcelProperty(value = "年龄") + private Integer age; + + /** + * 品种 + */ + @ExcelProperty(value = "品种") + private String category; + + public Cat() { + } + + public Cat(String nickName, Integer age, String category) { + this.nickName = nickName; + this.age = age; + this.category = category; + } + + public String getNickName() { + return nickName; + } + + public Cat setNickName(String nickName) { + this.nickName = nickName; + return this; + } + + public Integer getAge() { + return age; + } + + public Cat setAge(Integer age) { + this.age = age; + return this; + } + + public String getCategory() { + return category; + } + + public Cat setCategory(String category) { + this.category = category; + return this; + } +} diff --git a/SpringBootDemoV3/src/main/java/com/xiaour/spring/boot/entity/PageIndex.java b/SpringBootDemoV3/src/main/java/com/xiaour/spring/boot/entity/PageIndex.java new file mode 100644 index 0000000..abaf3dc --- /dev/null +++ b/SpringBootDemoV3/src/main/java/com/xiaour/spring/boot/entity/PageIndex.java @@ -0,0 +1,24 @@ +package com.xiaour.spring.boot.entity; + +public class PageIndex { + + private Integer pageIndex; + + private Integer pageSize; + + public Integer getPageIndex() { + return pageIndex; + } + + public void setPageIndex(Integer pageIndex) { + this.pageIndex = pageIndex; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } +} diff --git a/SpringBootDemoV3/src/main/java/com/xiaour/spring/boot/entity/PageInfo.java b/SpringBootDemoV3/src/main/java/com/xiaour/spring/boot/entity/PageInfo.java new file mode 100644 index 0000000..53fafdd --- /dev/null +++ b/SpringBootDemoV3/src/main/java/com/xiaour/spring/boot/entity/PageInfo.java @@ -0,0 +1,26 @@ +package com.xiaour.spring.boot.entity; + +import java.util.List; + +public class PageInfo { + + private List list; + + private Integer total; + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + public Integer getTotal() { + return total; + } + + public void setTotal(Integer total) { + this.total = total; + } +} diff --git a/SpringBootDemoV3/src/main/java/com/xiaour/spring/boot/service/CatService.java b/SpringBootDemoV3/src/main/java/com/xiaour/spring/boot/service/CatService.java new file mode 100644 index 0000000..ba1b8c1 --- /dev/null +++ b/SpringBootDemoV3/src/main/java/com/xiaour/spring/boot/service/CatService.java @@ -0,0 +1,44 @@ +package com.xiaour.spring.boot.service; + +import com.github.xiaour.easyexport.annotation.EasyExport; +import com.github.xiaour.easyexport.annotation.EasyExportSingle; +import com.xiaour.spring.boot.entity.Cat; +import com.xiaour.spring.boot.entity.PageIndex; +import com.xiaour.spring.boot.entity.PageInfo; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@EasyExport +@Service +public class CatService { + + /** + * 这里主要是模拟数据和分页参数的一些主要逻辑 + * @param pageIndex 模拟的分页参数,这里面是伪代码,无需实现 + * @return + */ + @EasyExportSingle(value = "小猫明细",modelClass = Cat.class) + public PageInfo getCatList(PageIndex pageIndex){ + + PageInfo page = new PageInfo(); + + List list = new ArrayList<>(); + + //下面提供了两种实体赋值方式,大家可以试试那种更方便 + Cat cat1 = new Cat("咪咪",1,"波斯猫"); + + Cat cat2 = new Cat().setNickName("汤姆").setAge(6).setCategory("金渐层"); + + list.add(cat1); + + list.add(cat2); + + page.setList(list); + + page.setTotal(list.size()); + + return page; + } +} diff --git a/SpringBootDemoV3/src/main/resources/application.properties b/SpringBootDemoV3/src/main/resources/application.properties new file mode 100644 index 0000000..a39567d --- /dev/null +++ b/SpringBootDemoV3/src/main/resources/application.properties @@ -0,0 +1,15 @@ +server.servlet.context-path= /demo3 + +#??easyexport +easyexport.enabled=true +#?????? +#?????????? +easyexport.fetch.page.size=5000 +#???????????????????true??????? +easyexport.file.delete=true +#???????????????????Sheet????sheet???150000 +easyexport.file.sheet.size=15000 +#???? +easyexport.field.page.number=pageIndex +#??????? +easyexport.field.page.size=pageSize \ No newline at end of file diff --git a/SpringBootDemoV3/src/test/java/com/xiaour/spring/boot/SpringBootDemoV3ApplicationTests.java b/SpringBootDemoV3/src/test/java/com/xiaour/spring/boot/SpringBootDemoV3ApplicationTests.java new file mode 100644 index 0000000..bbe9d67 --- /dev/null +++ b/SpringBootDemoV3/src/test/java/com/xiaour/spring/boot/SpringBootDemoV3ApplicationTests.java @@ -0,0 +1,13 @@ +package com.xiaour.spring.boot; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class SpringBootDemoV3ApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/SpringBootKafkaDemo/.mvn/wrapper/maven-wrapper.jar b/SpringBootKafkaDemo/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index 9cc84ea..0000000 Binary files a/SpringBootKafkaDemo/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/SpringBootKafkaDemo/.mvn/wrapper/maven-wrapper.properties b/SpringBootKafkaDemo/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index b573bb5..0000000 --- a/SpringBootKafkaDemo/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1 +0,0 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip diff --git a/SpringBootKafkaDemo/pom.xml b/SpringBootKafkaDemo/pom.xml index 60448e6..b0eb7a0 100644 --- a/SpringBootKafkaDemo/pom.xml +++ b/SpringBootKafkaDemo/pom.xml @@ -3,8 +3,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.xiaour.spring.boot - kafka + com.github.xiaour + KafkaDemo 0.0.1-SNAPSHOT jar @@ -43,15 +43,20 @@ com.google.code.gson gson - 2.8.2 + 2.8.9 org.springframework.boot spring-boot-starter-web - RELEASE + 2.5.12 + + org.springframework + spring-context + 5.2.22.RELEASE + - + diff --git a/SpringBootKafkaDemo/target/classes/application.yml b/SpringBootKafkaDemo/target/classes/application.yml deleted file mode 100644 index 0b19627..0000000 --- a/SpringBootKafkaDemo/target/classes/application.yml +++ /dev/null @@ -1,33 +0,0 @@ -server: - servlet: - context-path: / - port: 8080 -spring: - kafka: - bootstrap-servers: 127.0.0.1:9092 - #生产者的配置,大部分我们可以使用默认的,这里列出几个比较重要的属性 - producer: - #每批次发送消息的数量 - batch-size: 16 - #设置大于0的值将使客户端重新发送任何数据,一旦这些数据发送失败。注意,这些重试与客户端接收到发送错误时的重试没有什么不同。允许重试将潜在的改变数据的顺序,如果这两个消息记录都是发送到同一个partition,则第一个消息失败第二个发送成功,则第二条消息会比第一条消息出现要早。 - retries: 0 - #producer可以用来缓存数据的内存大小。如果数据产生速度大于向broker发送的速度,producer会阻塞或者抛出异常,以“block.on.buffer.full”来表明。这项设置将和producer能够使用的总内存相关,但并不是一个硬性的限制,因为不是producer使用的所有内存都是用于缓存。一些额外的内存会用于压缩(如果引入压缩机制),同样还有一些用于维护请求。 - buffer-memory: 33554432 - #key序列化方式 - key-serializer: org.apache.kafka.common.serialization.StringSerializer - value-serializer: org.apache.kafka.common.serialization.StringSerializer - #消费者的配置 - consumer: - #Kafka中没有初始偏移或如果当前偏移在服务器上不再存在时,默认区最新 ,有三个选项 【latest, earliest, none】 - auto-offset-reset: latest - #是否开启自动提交 - enable-auto-commit: true - #自动提交的时间间隔 - auto-commit-interval: 100 - #key的解码方式 - key-deserializer: org.apache.kafka.common.serialization.StringDeserializer - #value的解码方式 - value-deserializer: org.apache.kafka.common.serialization.StringDeserializer - #在/usr/local/etc/kafka/consumer.properties中有配置 - group-id: test-consumer-group - diff --git a/SpringBootKafkaDemo/target/classes/com/xiaour/spring/boot/kafka/KafkaApplication.class b/SpringBootKafkaDemo/target/classes/com/xiaour/spring/boot/kafka/KafkaApplication.class deleted file mode 100644 index 2c3c15f..0000000 Binary files a/SpringBootKafkaDemo/target/classes/com/xiaour/spring/boot/kafka/KafkaApplication.class and /dev/null differ diff --git a/SpringBootKafkaDemo/target/classes/com/xiaour/spring/boot/kafka/consumer/Consumer.class b/SpringBootKafkaDemo/target/classes/com/xiaour/spring/boot/kafka/consumer/Consumer.class deleted file mode 100644 index ff302fb..0000000 Binary files a/SpringBootKafkaDemo/target/classes/com/xiaour/spring/boot/kafka/consumer/Consumer.class and /dev/null differ diff --git a/SpringBootKafkaDemo/target/classes/com/xiaour/spring/boot/kafka/producer/Message.class b/SpringBootKafkaDemo/target/classes/com/xiaour/spring/boot/kafka/producer/Message.class index 925fbed..9b6edd7 100644 Binary files a/SpringBootKafkaDemo/target/classes/com/xiaour/spring/boot/kafka/producer/Message.class and b/SpringBootKafkaDemo/target/classes/com/xiaour/spring/boot/kafka/producer/Message.class differ diff --git a/SpringBootKafkaDemo/target/classes/com/xiaour/spring/boot/kafka/producer/Producer.class b/SpringBootKafkaDemo/target/classes/com/xiaour/spring/boot/kafka/producer/Producer.class deleted file mode 100644 index e9d87c3..0000000 Binary files a/SpringBootKafkaDemo/target/classes/com/xiaour/spring/boot/kafka/producer/Producer.class and /dev/null differ diff --git a/SpringBootKafkaDemo/target/classes/com/xiaour/spring/boot/kafka/producer/SendController.class b/SpringBootKafkaDemo/target/classes/com/xiaour/spring/boot/kafka/producer/SendController.class deleted file mode 100644 index a532e7e..0000000 Binary files a/SpringBootKafkaDemo/target/classes/com/xiaour/spring/boot/kafka/producer/SendController.class and /dev/null differ diff --git a/SpringBootKafkaDemo/target/test-classes/com/xiaour/spring/boot/kafka/KafkaApplicationTests.class b/SpringBootKafkaDemo/target/test-classes/com/xiaour/spring/boot/kafka/KafkaApplicationTests.class deleted file mode 100644 index 3c908bf..0000000 Binary files a/SpringBootKafkaDemo/target/test-classes/com/xiaour/spring/boot/kafka/KafkaApplicationTests.class and /dev/null differ diff --git a/SpringBootRocketMqDemo/pom.xml b/SpringBootRocketMqDemo/pom.xml index e8cee00..d02e456 100644 --- a/SpringBootRocketMqDemo/pom.xml +++ b/SpringBootRocketMqDemo/pom.xml @@ -3,13 +3,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.xiaour.spring.boot - rocketmq + com.github.xiaour + rocketmqDemo 0.0.1-SNAPSHOT - jar - SpringBootRocketmqDemo - Demo project for Spring Boot + Demo project for RocketMQ + jar org.springframework.boot @@ -45,7 +44,7 @@ org.springframework.boot spring-boot-starter-web - RELEASE + 2.5.12 diff --git a/SpringWebFluxDemo/.gitignore b/SpringWebFluxDemo/.gitignore new file mode 100644 index 0000000..ba5cb5c --- /dev/null +++ b/SpringWebFluxDemo/.gitignore @@ -0,0 +1,26 @@ +HELP.md +/target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +/build/ diff --git a/SpringWebFluxDemo/pom.xml b/SpringWebFluxDemo/pom.xml new file mode 100644 index 0000000..f98a09c --- /dev/null +++ b/SpringWebFluxDemo/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.3.RELEASE + + + com.github.xiaour + fluxDemo + 0.0.1-SNAPSHOT + SpringWebFluxDemo + Demo project for Web Flux + + + 1.8 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-webflux + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/SpringWebFluxDemo/src/main/java/com/github/xiaour/flux/SpringWebFluxDemoApplication.java b/SpringWebFluxDemo/src/main/java/com/github/xiaour/flux/SpringWebFluxDemoApplication.java new file mode 100644 index 0000000..d13a52c --- /dev/null +++ b/SpringWebFluxDemo/src/main/java/com/github/xiaour/flux/SpringWebFluxDemoApplication.java @@ -0,0 +1,13 @@ +package com.github.xiaour.flux; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringWebFluxDemoApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringWebFluxDemoApplication.class, args); + } + +} diff --git a/SpringWebFluxDemo/src/main/java/com/github/xiaour/flux/controller/HelloWorlController.java b/SpringWebFluxDemo/src/main/java/com/github/xiaour/flux/controller/HelloWorlController.java new file mode 100644 index 0000000..f45ae29 --- /dev/null +++ b/SpringWebFluxDemo/src/main/java/com/github/xiaour/flux/controller/HelloWorlController.java @@ -0,0 +1,24 @@ +package com.github.xiaour.flux.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import reactor.core.publisher.Mono; + +/** + * @Author: cityuu@163.com + * @Date: 2019-02-27 16:26 + * @version: v1.0 + * @Description: 入门案例 + */ + +@RestController +@RequestMapping("/") +public class HelloWorlController { + + @GetMapping("hello") + public Mono hello(){ + return Mono.just("hello World!"); + } + +} diff --git a/SpringWebFluxDemo/src/main/java/com/github/xiaour/flux/controller/SSEController.java b/SpringWebFluxDemo/src/main/java/com/github/xiaour/flux/controller/SSEController.java new file mode 100644 index 0000000..dbbba46 --- /dev/null +++ b/SpringWebFluxDemo/src/main/java/com/github/xiaour/flux/controller/SSEController.java @@ -0,0 +1,34 @@ +package com.github.xiaour.flux.controller; + +import io.netty.util.internal.ThreadLocalRandom; +import org.springframework.http.codec.ServerSentEvent; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import reactor.core.publisher.Flux; +import reactor.util.function.Tuples; + +import java.time.Duration; + +/** + * @Author: cityuu@163.com + * @Date: 2019-02-27 16:37 + * @version: v1.0 + * @Description: 服务器推送接口 + */ +@RestController +@RequestMapping("/sse") +public class SSEController { + + @GetMapping("/randomNumbers") + public Flux> randomNumbers() { + return Flux.interval(Duration.ofSeconds(2)) + .map(seq -> Tuples.of(seq, ThreadLocalRandom.current().nextInt())) + .map(data -> ServerSentEvent.builder() + .event("random") + .id(Long.toString(data.getT1())) + .data(data.getT2()) + .build()); + } + +} diff --git a/SpringWebFluxDemo/src/main/java/com/github/xiaour/flux/controller/UserController.java b/SpringWebFluxDemo/src/main/java/com/github/xiaour/flux/controller/UserController.java new file mode 100644 index 0000000..823df9b --- /dev/null +++ b/SpringWebFluxDemo/src/main/java/com/github/xiaour/flux/controller/UserController.java @@ -0,0 +1,53 @@ +package com.github.xiaour.flux.controller; + +import com.github.xiaour.flux.entity.User; +import com.github.xiaour.flux.service.UserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import java.util.Objects; + +/** + * @Author: cityuu@163.com + * @Date: 2019-02-27 16:33 + * @version: v1.0 + * @Description: 用户管理接口 + */ +@RestController +@RequestMapping("/user") +public class UserController { + + @Autowired + private UserService userService; + + + @GetMapping("") + public Flux list() { + return userService.list(); + } + + @GetMapping("/{id}") + public Mono getById(@PathVariable("id") final String id) { + return this.userService.getById(id); + } + + @PostMapping("") + public Mono create(@RequestBody final User user) { + return this.userService.createOrUpdate(user); + } + + @PutMapping("/{id}") + public Mono update(@PathVariable("id") final String id, @RequestBody final User user) { + Objects.requireNonNull(user); + user.setId(id); + return this.userService.createOrUpdate(user); + } + + @DeleteMapping("/{id}") + public Mono delete(@PathVariable("id") final String id) { + return this.userService.delete(id); + } + +} diff --git a/SpringWebFluxDemo/src/main/java/com/github/xiaour/flux/entity/User.java b/SpringWebFluxDemo/src/main/java/com/github/xiaour/flux/entity/User.java new file mode 100644 index 0000000..9a9f9a5 --- /dev/null +++ b/SpringWebFluxDemo/src/main/java/com/github/xiaour/flux/entity/User.java @@ -0,0 +1,40 @@ +package com.github.xiaour.flux.entity; + +/** + * @Author: cityuu@suiyueyule.com + * @Date: 2019-02-27 16:31 + * @version: v1.0 + * @Description: + */ +public class User { + + private String id; + + private String name; + + private Integer age; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } +} diff --git a/SpringWebFluxDemo/src/main/java/com/github/xiaour/flux/service/UserService.java b/SpringWebFluxDemo/src/main/java/com/github/xiaour/flux/service/UserService.java new file mode 100644 index 0000000..0d39680 --- /dev/null +++ b/SpringWebFluxDemo/src/main/java/com/github/xiaour/flux/service/UserService.java @@ -0,0 +1,44 @@ +package com.github.xiaour.flux.service; + +import com.github.xiaour.flux.entity.User; +import org.springframework.stereotype.Service; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * @Author: cityuu@suiyueyule.com + * @Date: 2019-02-27 16:30 + * @version: v1.0 + * @Description: + */ +@Service +public class UserService { + + private final Map data = new ConcurrentHashMap<>(); + + public Flux list() { + return Flux.fromIterable(this.data.values()); + } + + public Flux getById(final Flux ids) { + return ids.flatMap(id -> Mono.justOrEmpty(this.data.get(id))); + } + + public Mono getById(final String id) { + return Mono.justOrEmpty(this.data.get(id)); + } + + public Mono createOrUpdate(final User user) { + this.data.put(user.getId(), user); + return Mono.just(user); + } + + public Mono delete(final String id) { + return Mono.justOrEmpty(this.data.remove(id)); + } + + +} diff --git a/SpringWebFluxDemo/src/main/resources/application.properties b/SpringWebFluxDemo/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/SpringWebFluxDemo/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/SpringWebFluxDemo/src/test/java/com/github/xiaour/flux/SpringWebFluxDemoApplicationTests.java b/SpringWebFluxDemo/src/test/java/com/github/xiaour/flux/SpringWebFluxDemoApplicationTests.java new file mode 100644 index 0000000..d2b3784 --- /dev/null +++ b/SpringWebFluxDemo/src/test/java/com/github/xiaour/flux/SpringWebFluxDemoApplicationTests.java @@ -0,0 +1,16 @@ +package com.github.xiaour.flux; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class SpringWebFluxDemoApplicationTests { + + @Test + public void contextLoads() { + } + +} diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..028c717 --- /dev/null +++ b/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + com.github.xiaour + com.xiaour.spring.boot + 0.0.1-SNAPSHOT + SpringBootDemo + SpringBoot set demo + pom + + + SpringBootDemo + SpringBootDemoV2 + SpringBootDemoV3 + SpringBootKafkaDemo + SpringBootRocketMqDemo + SpringWebFluxDemo + + + + + 17 + + +