diff --git a/README.md b/README.md index 6bcc1ef3b5d21ba60df3b76db866606fcccc53fa..e943d05c1b1f0130abc9e2402a3817a67e1bf887 100644 --- a/README.md +++ b/README.md @@ -31,5 +31,5 @@ SpringBoot应用集合 - [springboot-pagehelper实现分页查询](https://gitee.com/superbutton/SpringBoot-Components/tree/develop/Springboot-pagehelper) - [springboot-async实现异步](https://gitee.com/superbutton/SpringBoot-Components/tree/develop/springboot-async) - [springboot-nacos注册中心](https://gitee.com/superbutton/SpringBoot-Components/tree/develop/springboot-nacos) - +- [springboot整合SmartDoc](https://gitee.com/superbutton/SpringBoot-Components/tree/develop/Springboot-SmartDoc) diff --git a/Springboot-SmartDoc/.gitignore b/Springboot-SmartDoc/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..b83d22266ac8aa2f8df2edef68082c789727841d --- /dev/null +++ b/Springboot-SmartDoc/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/Springboot-SmartDoc/README.MD b/Springboot-SmartDoc/README.MD new file mode 100644 index 0000000000000000000000000000000000000000..1a8912a7558a4e523cdcdb0437c8ece6999c5309 --- /dev/null +++ b/Springboot-SmartDoc/README.MD @@ -0,0 +1,17 @@ +# 本案例主要实现SpringBoot多模块项目整合Smart-Doc +``` +整合大致思路: +1、pom中添加相关插件依赖 +2、编辑smart-doc.json文件 +3、使用命令生成 +4、如果生成的文档想要直接调用相关接口,必须添加CorsFilter +``` +``` +特别注意:生成文档要求注释必须规范,否则会生成失败 +system-one项目生成文档 +mvn -X smart-doc:html -Dfile.encoding=UTF-8 -pl system-one -am +system-two项目生成文档 +mvn -X smart-doc:html -Dfile.encoding=UTF-8 -pl system-two -am + +生成的路径可以再smart-doc.json中进行配置(outPath) +``` \ No newline at end of file diff --git a/Springboot-SmartDoc/common/pom.xml b/Springboot-SmartDoc/common/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..cf8a76a260b36f7e9dcd7a9ca7057cfbe17eea3c --- /dev/null +++ b/Springboot-SmartDoc/common/pom.xml @@ -0,0 +1,28 @@ + + + + Springboot-SmartDoc + com.button + 1.0-SNAPSHOT + + 4.0.0 + + com.button + common + 1.0-SNAPSHOT + + + 8 + 8 + + + + + org.projectlombok + lombok + provided + + + \ No newline at end of file diff --git a/Springboot-SmartDoc/common/src/main/java/com/button/domain/ResultData.java b/Springboot-SmartDoc/common/src/main/java/com/button/domain/ResultData.java new file mode 100644 index 0000000000000000000000000000000000000000..799a0af7a1cd33c2c696978d43f4c6121bc6cf5e --- /dev/null +++ b/Springboot-SmartDoc/common/src/main/java/com/button/domain/ResultData.java @@ -0,0 +1,118 @@ +package com.button.domain; + +import java.io.Serializable; + +/** + * 响应实体类 + * @author button + * @Description + * @create 2022/7/14 + */ +public class ResultData implements Serializable { + private static final long serialVersionUID = 1L; + public static final ErrorMsg SUCCESS = new ErrorMsg("success", "操作成功"); + public static final ErrorMsg EXCEPTION = new ErrorMsg("exception", "系统忙,请稍后重试"); + public static final ErrorMsg REQUEST_FAILED = new ErrorMsg("request.failed", "网络请求异常"); + public static final ErrorMsg ERROR_NO_DATA = new ErrorMsg("error.no.data", "无数据"); + public static final ErrorMsg ERROR_PARA_IS_NULL = new ErrorMsg("error.para.is.null", "请求参数PARA_NAME未设定"); + /** + * 响应errorMsg实体 + */ + private ErrorMsg errorMsg; + /** + * 响应结果 + */ + private T data; + /** + * 响应时间 + */ + private Integer time; + + public static ResultData ok(T data) { + ResultData result = new ResultData(); + result.setErrorMsg(SUCCESS); + result.setData(data); + return result; + } + + public static ResultData error(ErrorMsg error) { + ResultData result = new ResultData(); + result.setErrorMsg(error); + return result; + } + + public Integer getTime() { + return time; + } + + public void setTime(Integer time) { + this.time = time; + } + + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } + + public ErrorMsg getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(ErrorMsg errorMsg) { + this.errorMsg = errorMsg; + } + + public boolean isSuccessful() { + return SUCCESS.getCode().equals(this.errorMsg.getCode()); + } + + public boolean errorFor(ErrorMsg errMsg) { + return this.errorMsg.getCode().equalsIgnoreCase(errMsg.getCode()); + } + + public static class ErrorMsg implements Serializable { + private static final long serialVersionUID = -8899306544168830547L; + /** + * 响应code + */ + private String code; + /** + * 响应信息 + */ + private String message; + + public ErrorMsg(String code, String message) { + this.code = code; + this.message = message; + } + + public String getCode() { + return this.code; + } + + public String getMessage() { + return this.message; + } + + public ErrorMsg setParam(String key, String value) { + return new ErrorMsg(this.code, this.message.replace(key, value)); + } + + public ErrorMsg withParam(String value) { + return setParam("PARA_NAME", value); + } + + @Override + public String toString() { + return "[code=" + code + ", message=" + message + "]"; + } + } + + @Override + public String toString() { + return "[errorMsg=" + errorMsg + ", data=" + data + "]"; + } +} diff --git a/Springboot-SmartDoc/common/src/main/java/com/button/domain/request/SystemOneRequest.java b/Springboot-SmartDoc/common/src/main/java/com/button/domain/request/SystemOneRequest.java new file mode 100644 index 0000000000000000000000000000000000000000..9fde5f1adfeb3400fd3654b27174e3740de7a09e --- /dev/null +++ b/Springboot-SmartDoc/common/src/main/java/com/button/domain/request/SystemOneRequest.java @@ -0,0 +1,21 @@ +package com.button.domain.request; + +import lombok.Data; + +/** + * 系统1请求参数实体 + * @author button + * @Description + * @create 2022/7/14 + */ +@Data +public class SystemOneRequest { + /** + * 姓名 + */ + private String name; + /** + * 地址 + */ + private String addr; +} diff --git a/Springboot-SmartDoc/common/src/main/java/com/button/domain/request/SystemTwoRequest.java b/Springboot-SmartDoc/common/src/main/java/com/button/domain/request/SystemTwoRequest.java new file mode 100644 index 0000000000000000000000000000000000000000..f6c060efa11c5d885db3ea601012d2aefd52a2f9 --- /dev/null +++ b/Springboot-SmartDoc/common/src/main/java/com/button/domain/request/SystemTwoRequest.java @@ -0,0 +1,21 @@ +package com.button.domain.request; + +import lombok.Data; + +/** + * 系统2请求参数实体 + * @author button + * @Description + * @create 2022/7/14 + */ +@Data +public class SystemTwoRequest { + /** + * 姓名 + */ + private Integer age; + /** + * 性别 + */ + private String gender; +} diff --git a/Springboot-SmartDoc/common/src/main/java/com/button/domain/response/SystemOneResponse.java b/Springboot-SmartDoc/common/src/main/java/com/button/domain/response/SystemOneResponse.java new file mode 100644 index 0000000000000000000000000000000000000000..2eb0cac43cfc38bb63266a1afe2ecc24d1e34842 --- /dev/null +++ b/Springboot-SmartDoc/common/src/main/java/com/button/domain/response/SystemOneResponse.java @@ -0,0 +1,23 @@ +package com.button.domain.response; + +import lombok.Builder; +import lombok.Data; + +/** + * 系统1请求响应实体 + * @author button + * @Description + * @create 2022/7/14 + */ +@Data +@Builder +public class SystemOneResponse { + /** + * 姓名 + */ + private String name; + /** + * 地址 + */ + private String addr; +} diff --git a/Springboot-SmartDoc/common/src/main/java/com/button/domain/response/SystemTwoResponse.java b/Springboot-SmartDoc/common/src/main/java/com/button/domain/response/SystemTwoResponse.java new file mode 100644 index 0000000000000000000000000000000000000000..585fd1a09df88c541d782f667bb50ded55808f6f --- /dev/null +++ b/Springboot-SmartDoc/common/src/main/java/com/button/domain/response/SystemTwoResponse.java @@ -0,0 +1,23 @@ +package com.button.domain.response; + +import lombok.Builder; +import lombok.Data; + +/** + * 系统2响应实体 + * @author button + * @Description + * @create 2022/7/14 + */ +@Data +@Builder +public class SystemTwoResponse { + /** + * 姓名 + */ + private Integer age; + /** + * 性别 + */ + private String gender; +} diff --git a/Springboot-SmartDoc/pom.xml b/Springboot-SmartDoc/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..ab3b4e1bcba4dd3f2324065216bc5cbc59d3f2c9 --- /dev/null +++ b/Springboot-SmartDoc/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + + com.button + Springboot-SmartDoc + 1.0-SNAPSHOT + + common + system-one + system-two + + pom + + + org.springframework.boot + spring-boot-starter-parent + 2.5.6 + + + + + UTF-8 + 8 + 8 + + + + + + + + com.github.shalousun + smart-doc-maven-plugin + 2.4.8 + + + ${basedir}/src/main/resources/smart-doc.json + + ${project.artifactId} + + + + + html + + + + + + + + \ No newline at end of file diff --git a/Springboot-SmartDoc/system-one/pom.xml b/Springboot-SmartDoc/system-one/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..449552cfd631b1ee152a6baa5e007159c551a644 --- /dev/null +++ b/Springboot-SmartDoc/system-one/pom.xml @@ -0,0 +1,65 @@ + + + + Springboot-SmartDoc + com.button + 1.0-SNAPSHOT + + 4.0.0 + + system-one + com.button + 1.0-SNAPSHOT + + + 8 + 8 + + + + + com.button + common + 1.0-SNAPSHOT + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-web + + + + + system-one + + + org.springframework.boot + spring-boot-maven-plugin + + true + true + + + + com.github.shalousun + smart-doc-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + ${java.version} + ${java.version} + UTF-8 + + + + + + \ No newline at end of file diff --git a/Springboot-SmartDoc/system-one/src/main/java/com/button/systemone/SystemOneApplication.java b/Springboot-SmartDoc/system-one/src/main/java/com/button/systemone/SystemOneApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..df7f4f17dc9bb0c43a62af4b8836a8d51ba0cd9e --- /dev/null +++ b/Springboot-SmartDoc/system-one/src/main/java/com/button/systemone/SystemOneApplication.java @@ -0,0 +1,16 @@ +package com.button.systemone; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @author button + * @Description + * @create 2022/7/14 + */ +@SpringBootApplication +public class SystemOneApplication { + public static void main(String[] args) { + SpringApplication.run(SystemOneApplication.class, args); + } +} diff --git a/Springboot-SmartDoc/system-one/src/main/java/com/button/systemone/config/WebMvcAutoConfig.java b/Springboot-SmartDoc/system-one/src/main/java/com/button/systemone/config/WebMvcAutoConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..405d11d71b9e7144fcb034b662201a72618a669a --- /dev/null +++ b/Springboot-SmartDoc/system-one/src/main/java/com/button/systemone/config/WebMvcAutoConfig.java @@ -0,0 +1,33 @@ +package com.button.systemone.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +/** + * @author ZhangHang + * @Description + * @create 2022/5/20 + */ +@Configuration +public class WebMvcAutoConfig implements WebMvcConfigurer { + + @Bean + public CorsFilter corsFilter() { + final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource(); + final CorsConfiguration corsConfiguration = new CorsConfiguration(); + /* 是否允许请求带有验证信息 */ + corsConfiguration.setAllowCredentials(true); + /* 允许访问的客户端域名 */ + corsConfiguration.addAllowedOriginPattern("*"); + /* 允许服务端访问的客户端请求头 */ + corsConfiguration.addAllowedHeader("*"); + /* 允许访问的方法名,GET POST等 */ + corsConfiguration.addAllowedMethod("*"); + urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration); + return new CorsFilter(urlBasedCorsConfigurationSource); + } +} \ No newline at end of file diff --git a/Springboot-SmartDoc/system-one/src/main/java/com/button/systemone/controller/SystemOneController.java b/Springboot-SmartDoc/system-one/src/main/java/com/button/systemone/controller/SystemOneController.java new file mode 100644 index 0000000000000000000000000000000000000000..8f2735ec66e4c425c9c898b9a99d3fd9539b47ea --- /dev/null +++ b/Springboot-SmartDoc/system-one/src/main/java/com/button/systemone/controller/SystemOneController.java @@ -0,0 +1,32 @@ +package com.button.systemone.controller; + +import com.button.domain.ResultData; +import com.button.domain.request.SystemOneRequest; +import com.button.domain.response.SystemOneResponse; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * 系统1测试接口 + * @author button + * @Description 系统1测试接口 + * @create 2022/7/14 + */ +@RestController +public class SystemOneController { + + /** + * 系统1保存信息 + * @Description: 系统1保存信息 + * @author ZhangHang + * @param systemOneRequest 系统1保存信息请求实体 + * @return com.button.domain.ResultData + * @date 2022/7/14 14:22 + */ + @PostMapping(value = "saveSysOneInfo") + public ResultData saveSysOneInfo(@RequestBody SystemOneRequest systemOneRequest){ + SystemOneResponse systemOneResponse = SystemOneResponse.builder().name(systemOneRequest.getName()).addr(systemOneRequest.getAddr()).build(); + return ResultData.ok(systemOneResponse); + } +} diff --git a/Springboot-SmartDoc/system-one/src/main/resources/application.yml b/Springboot-SmartDoc/system-one/src/main/resources/application.yml new file mode 100644 index 0000000000000000000000000000000000000000..54b155fffd11fee84bd0ce1152f747d9ebe47f51 --- /dev/null +++ b/Springboot-SmartDoc/system-one/src/main/resources/application.yml @@ -0,0 +1,2 @@ +server: + port: 8081 \ No newline at end of file diff --git a/Springboot-SmartDoc/system-one/src/main/resources/smart-doc.json b/Springboot-SmartDoc/system-one/src/main/resources/smart-doc.json new file mode 100644 index 0000000000000000000000000000000000000000..4210987b2cc28b2bf7173178d1d882573b4630ce --- /dev/null +++ b/Springboot-SmartDoc/system-one/src/main/resources/smart-doc.json @@ -0,0 +1,44 @@ +{ + "serverUrl": "http://127.0.0.1:9080", + "pathPrefix": "", + "isStrict": false, + "allInOne": true, + "outPath": "target/docs", + "coverOld": true, + "createDebugPage": true, + "packageFilters": "com.button.systemone.controller.*", + "md5EncryptedHtmlName": false, + "style":"atelier-cave-light", + "projectName": "systemone", + "framework": "spring", + "skipTransientField": true, + "sortByTitle":false, + "showAuthor":true, + "requestFieldToUnderline":false, + "responseFieldToUnderline":false, + "inlineEnum":true, + "recursionLimit":7, + "allInOneDocFileName":"systemone-doc.html", + "requestExample":"true", + "responseExample":"true", + "displayActualType":true, + "revisionLogs": [{ + "version": "1.0", + "revisionTime": "2022-07-14 14:30", + "status": "update", + "author": "zhanghang", + "remarks": "系统1操作说明" + }], + "requestHeaders": [ + { + "name": "token", + "type": "string", + "desc": "请求token,通过登录接口获取", + "value":"登录后获取token字符串", + "required": true + } + ], + "responseBodyAdvice":{ + "className":"com.button.domain.ResultData" + } +} \ No newline at end of file diff --git a/Springboot-SmartDoc/system-two/pom.xml b/Springboot-SmartDoc/system-two/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..24da0023458ff4be92d7a33f2f1cbf7d3e84826c --- /dev/null +++ b/Springboot-SmartDoc/system-two/pom.xml @@ -0,0 +1,65 @@ + + + + Springboot-SmartDoc + com.button + 1.0-SNAPSHOT + + 4.0.0 + + com.button + system-two + 1.0-SNAPSHOT + + + 8 + 8 + + + + + com.button + common + 1.0-SNAPSHOT + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-web + + + + + system-two + + + org.springframework.boot + spring-boot-maven-plugin + + true + true + + + + com.github.shalousun + smart-doc-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + ${java.version} + ${java.version} + UTF-8 + + + + + + \ No newline at end of file diff --git a/Springboot-SmartDoc/system-two/src/main/java/com/button/systemtwo/SystemTwoApplication.java b/Springboot-SmartDoc/system-two/src/main/java/com/button/systemtwo/SystemTwoApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..9bdd3fe3323c47bdbad8997f46ff9eb39138c48d --- /dev/null +++ b/Springboot-SmartDoc/system-two/src/main/java/com/button/systemtwo/SystemTwoApplication.java @@ -0,0 +1,16 @@ +package com.button.systemtwo; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @author button + * @Description + * @create 2022/7/14 + */ +@SpringBootApplication +public class SystemTwoApplication { + public static void main(String[] args) { + SpringApplication.run(SystemTwoApplication.class, args); + } +} diff --git a/Springboot-SmartDoc/system-two/src/main/java/com/button/systemtwo/config/WebMvcAutoConfig.java b/Springboot-SmartDoc/system-two/src/main/java/com/button/systemtwo/config/WebMvcAutoConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..9d68354f73dbf7f39bd62018ace2729a51d090d9 --- /dev/null +++ b/Springboot-SmartDoc/system-two/src/main/java/com/button/systemtwo/config/WebMvcAutoConfig.java @@ -0,0 +1,33 @@ +package com.button.systemtwo.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +/** + * @author ZhangHang + * @Description + * @create 2022/5/20 + */ +@Configuration +public class WebMvcAutoConfig implements WebMvcConfigurer { + + @Bean + public CorsFilter corsFilter() { + final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource(); + final CorsConfiguration corsConfiguration = new CorsConfiguration(); + /* 是否允许请求带有验证信息 */ + corsConfiguration.setAllowCredentials(true); + /* 允许访问的客户端域名 */ + corsConfiguration.addAllowedOriginPattern("*"); + /* 允许服务端访问的客户端请求头 */ + corsConfiguration.addAllowedHeader("*"); + /* 允许访问的方法名,GET POST等 */ + corsConfiguration.addAllowedMethod("*"); + urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration); + return new CorsFilter(urlBasedCorsConfigurationSource); + } +} \ No newline at end of file diff --git a/Springboot-SmartDoc/system-two/src/main/java/com/button/systemtwo/controller/SystemTwoController.java b/Springboot-SmartDoc/system-two/src/main/java/com/button/systemtwo/controller/SystemTwoController.java new file mode 100644 index 0000000000000000000000000000000000000000..bfbb9e8b3344b526373c0c301d74de24192a8e0f --- /dev/null +++ b/Springboot-SmartDoc/system-two/src/main/java/com/button/systemtwo/controller/SystemTwoController.java @@ -0,0 +1,32 @@ +package com.button.systemtwo.controller; + +import com.button.domain.ResultData; +import com.button.domain.request.SystemTwoRequest; +import com.button.domain.response.SystemTwoResponse; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * 系统2测试接口 + * @author ZhangHang + * @Description 系统2测试接口 + * @create 2022/7/14 + */ +@RestController +public class SystemTwoController { + + /** + * 系统2保存信息 + * @Description: 系统2保存信息 + * @author ZhangHang + * @param systemTwoRequest 系统2保存信息请求实体 + * @return com.button.domain.ResultData + * @date 2022/7/14 14:22 + */ + @PostMapping(value = "saveSysOneInfo") + public ResultData saveSysOneInfo(@RequestBody SystemTwoRequest systemTwoRequest){ + SystemTwoResponse systemTwoResponse = SystemTwoResponse.builder().age(systemTwoRequest.getAge()).gender("男").build(); + return ResultData.ok(systemTwoResponse); + } +} diff --git a/Springboot-SmartDoc/system-two/src/main/resources/application.yml b/Springboot-SmartDoc/system-two/src/main/resources/application.yml new file mode 100644 index 0000000000000000000000000000000000000000..08841319ddfa21619eda3b8a3630b09fecee6692 --- /dev/null +++ b/Springboot-SmartDoc/system-two/src/main/resources/application.yml @@ -0,0 +1,2 @@ +server: + port: 8082 \ No newline at end of file diff --git a/Springboot-SmartDoc/system-two/src/main/resources/smart-doc.json b/Springboot-SmartDoc/system-two/src/main/resources/smart-doc.json new file mode 100644 index 0000000000000000000000000000000000000000..d81e41e9ed193a31ccd87b9d38303c7b16255dd0 --- /dev/null +++ b/Springboot-SmartDoc/system-two/src/main/resources/smart-doc.json @@ -0,0 +1,44 @@ +{ + "serverUrl": "http://127.0.0.1:8082", + "pathPrefix": "", + "isStrict": false, + "allInOne": true, + "outPath": "target/docs", + "coverOld": true, + "createDebugPage": true, + "packageFilters": "com.button.systemtwo.controller.*", + "md5EncryptedHtmlName": false, + "style":"atelier-cave-light", + "projectName": "systemtwo", + "framework": "spring", + "skipTransientField": true, + "sortByTitle":false, + "showAuthor":true, + "requestFieldToUnderline":false, + "responseFieldToUnderline":false, + "inlineEnum":true, + "recursionLimit":7, + "allInOneDocFileName":"systemtwo-doc.html", + "requestExample":"true", + "responseExample":"true", + "displayActualType":true, + "revisionLogs": [{ + "version": "1.0", + "revisionTime": "2022-07-14 14:30", + "status": "update", + "author": "button", + "remarks": "系统2操作说明" + }], + "requestHeaders": [ + { + "name": "token", + "type": "string", + "desc": "请求token,通过登录接口获取", + "value":"登录后获取token字符串", + "required": true + } + ], + "responseBodyAdvice":{ + "className":"com.button.domain.ResultData" + } +} \ No newline at end of file diff --git a/springboot-nacos/api-core/.gitignore b/springboot-nacos/api-core/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..b56f1dd0d04da4e03f710af3917e4fbdd9be4aa8 --- /dev/null +++ b/springboot-nacos/api-core/.gitignore @@ -0,0 +1,33 @@ +README.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/springboot-nacos/api-core/pom.xml b/springboot-nacos/api-core/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..e8b8b97b62e71f908039113799697235406bd390 --- /dev/null +++ b/springboot-nacos/api-core/pom.xml @@ -0,0 +1,54 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.5.3 + + + com.button + api-core + 0.0.1-SNAPSHOT + api-core + api-core + + 1.8 + + + + org.springframework.boot + spring-boot-starter + + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + diff --git a/springboot-nacos/api-core/src/main/java/com/button/ApiCoreApplication.java b/springboot-nacos/api-core/src/main/java/com/button/ApiCoreApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..9b609e3df88fa0d80f22027b3494bc62fa63a66e --- /dev/null +++ b/springboot-nacos/api-core/src/main/java/com/button/ApiCoreApplication.java @@ -0,0 +1,13 @@ +package com.button; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ApiCoreApplication { + + public static void main(String[] args) { + SpringApplication.run(ApiCoreApplication.class, args); + } + +} diff --git a/springboot-nacos/api-core/src/main/resources/application.properties b/springboot-nacos/api-core/src/main/resources/application.properties new file mode 100644 index 0000000000000000000000000000000000000000..8b137891791fe96927ad78e64b0aad7bded08bdc --- /dev/null +++ b/springboot-nacos/api-core/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/springboot-nacos/api-core/src/test/java/com/button/ApiCoreApplicationTests.java b/springboot-nacos/api-core/src/test/java/com/button/ApiCoreApplicationTests.java new file mode 100644 index 0000000000000000000000000000000000000000..cbed05f6fcee2770b5088ec864300dd9a5cb8dd9 --- /dev/null +++ b/springboot-nacos/api-core/src/test/java/com/button/ApiCoreApplicationTests.java @@ -0,0 +1,13 @@ +package com.button; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class ApiCoreApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/springboot-undertow/.gitignore b/springboot-undertow/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..b56f1dd0d04da4e03f710af3917e4fbdd9be4aa8 --- /dev/null +++ b/springboot-undertow/.gitignore @@ -0,0 +1,33 @@ +README.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/springboot-undertow/pom.xml b/springboot-undertow/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..59018f179d7ee5b0c6b6a3e4e525273c2d8be420 --- /dev/null +++ b/springboot-undertow/pom.xml @@ -0,0 +1,63 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.5.3 + + + com.button + springboot-undertow + 0.0.1-SNAPSHOT + springboot-undertow + springboot-undertow + + 1.8 + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + + + + + org.springframework.boot + spring-boot-starter-undertow + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + diff --git a/springboot-undertow/src/main/java/com/button/SpringBootUndertowApplication.java b/springboot-undertow/src/main/java/com/button/SpringBootUndertowApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..e691942820aa1cfde4e2c4aa5a44a0c650acdf33 --- /dev/null +++ b/springboot-undertow/src/main/java/com/button/SpringBootUndertowApplication.java @@ -0,0 +1,13 @@ +package com.button; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringBootUndertowApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringBootUndertowApplication.class, args); + } + +} diff --git a/springboot-undertow/src/main/java/com/button/controller.java b/springboot-undertow/src/main/java/com/button/controller.java new file mode 100644 index 0000000000000000000000000000000000000000..8b34e21ccadb919de30e1c22b701425485b33a98 --- /dev/null +++ b/springboot-undertow/src/main/java/com/button/controller.java @@ -0,0 +1,13 @@ +package com.button; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class controller { + + @GetMapping("/test") + public String get() { + return "Hello World!"; + } +} diff --git a/springboot-undertow/src/main/resources/application.yml b/springboot-undertow/src/main/resources/application.yml new file mode 100644 index 0000000000000000000000000000000000000000..5fdf1a86e58351ee0510b712f57d0ffd386fbf24 --- /dev/null +++ b/springboot-undertow/src/main/resources/application.yml @@ -0,0 +1,9 @@ +server: + port: 8808 + undertow: + io-threads: 16 #设置IO线程数, 它主要执行非阻塞的任务,它们会负责多个连接, 默认设置每个CPU核心一个线程,不要设置过大,如果过大,启动项目会报错:打开文件数过多 + worker-threads: 256 #阻塞任务线程池, 当执行类似servlet请求阻塞IO操作, undertow会从这个线程池中取得线程,它的值设置取决于系统线程执行任务的阻塞系数,默认值是IO线程数*8 + buffer-size: 1024 # 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理,每块buffer的空间大小,越小的空间被利用越充分,不要设置太大,以免影响其他应用,合适即可 + buffers-per-region: 1024 # 每个区分配的buffer数量 , 所以pool的大小是buffer-size * buffers-per-region + direct-buffers: true # 是否分配的直接内存(NIO直接分配的堆外内存) +