diff --git a/README.md b/README.md index 54a1949..361fab7 100644 --- a/README.md +++ b/README.md @@ -10,28 +10,29 @@ >powered by `Moshow郑锴(大狼狗)` , [https://zhengkai.blog.csdn.net](https://zhengkai.blog.csdn.net) # Description ->The `Spring Boot Code Generator` , Based on SpringBoot3 and Freemarker
-> #基于`SpringBoot3`和`Freemarker`的代码生成平台 -> ->Free your hands from tedious and repetitive CRUD work.
-> #解放你的双手,摆脱繁琐重复的CRUD工作。 -> ->Support mysql+oracle+pgsql , the most popular databases standard SQL
-> #支持`MySQL`、Oracle、PgSQL三大主流数据库 -> ->Generate various templates through table creation DDL statements, Insert SQL statements, Select SQL statements(*New), and simple JSON.
-> 通过建表DDL语句、插入SQL语句、选择SQL语句(*新)以及简单JSON生成各种模板`JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL/CommonMapper`. -> ->Thank you all for your use and feedback. The daily PV visits of 1.5k in BeJSON and 2K Stars on GitHub are the greatest encouragement and motivation.
-> 感谢大家的使用与反馈,BeJSON上每天1.5K的PV访问量👀和 Github上2K的✨Stars是最大的鼓励与动力。 -> ->May everyone maintain a work-life balance, stay healthy and safe. Wishing you all success in your work and continuous advancements!.
-> 愿大家可以维持生活和工作平衡,保持健康和安全,祝大家工作顺利,步步高升! -> ->Welcome to submit your issue and useful templates , or put your good idea into PR
-> 欢迎提交你的问题和常用有用模板,或者提交你的好主意到PR。 +> 🚀 `Spring Boot Code Generator` — a powerful code generation platform built on SpringBoot3 & Freemarker +> ✨ 基于 `SpringBoot3` 和 `Freemarker` 的高效代码生成平台 + +> 👐 Say goodbye to repetitive CRUD work — free your hands and boost productivity +> 💡 告别繁琐重复的 CRUD 操作,释放你的双手,让开发更高效! + +> 🛠️ Supports MySQL, Oracle, and PostgreSQL — the most popular SQL dialects +> 📦 支持主流数据库:`MySQL`、`Oracle`、`PgSQL`,标准 SQL 一网打尽 + +> ⚙️ Generate templates from DDL, INSERT SQL, SELECT SQL, or simple JSON — covering JPA, JdbcTemplate, Mybatis, MybatisPlus, BeetlSQL, CommonMapper +> 🧩 通过建表 DDL、插入 SQL、选择 SQL 或简单 JSON,一键生成 `JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL/CommonMapper` 等模板代码 + +> 🙏 Thanks for your continued support! BeJSON once peaked at 1.5K daily PV 👀, and now maintains a steady flow of around 600 visits — plus 2K+ GitHub Stars ✨. Your feedback remains our greatest motivation to keep improving! +> ❤️ 感谢大家一直以来的支持!BeJSON 曾创下日均访问量 1.5K 👀 的高峰,目前稳定在约 600 左右,GitHub Star 数也已突破 2K ✨。你们的反馈始终是我们不断前进的最大动力! + +> 🌈 Wishing everyone balance, health, and success — may your code be bug-free and your coffee strong ☕ +> 💬 祝大家工作顺利,生活平衡,身体健康,步步高升,代码无 bug,咖啡够劲! + +> 📬 Feel free to submit issues, share useful templates, or contribute your brilliant ideas via PR +> 🤝 欢迎提交问题、分享常用模板,或将你的灵感通过 PR 实现! + +> 🙌 Special thanks to BeJSON 前站长 `三叔` 的慧眼与支持,让项目得以脱颖而出,感恩! -> 特别感谢BeJSON前站长`三叔`的慧眼和支持,让该项目得以脱颖而出,谢谢! # URL @@ -67,7 +68,6 @@ - Master:主力分支,基于SpringBoot3+,需要JDK17+ - JDK11:兼容分支,版本落后,基于SpringBoot2+,但支持JDK8/JDK11等旧JDK版本[https://github.com/moshowgame/SpringBootCodeGenerator/tree/jdk11] - # 更新预告 1.计划加入AI来帮忙生成更多样式的模板 2.改进JSqlParser Engine (Select SQL and Create SQL) @@ -75,6 +75,7 @@ # Update Logs | 更新日期 | 更新内容 | |:-----------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| 2025.09.14 | 优化JSqlParser Engine(DDL Create SQL和Select SQL),适配更高级复杂的SQL | | 2025.09.13 | JSqlParser Engine全新升级,目前Select SQL模式相对稳定!
更新SpringBoot等类库版本,修复漏洞
修复CDN问题,切换为staticfile.org | | 2025.03.31 | 优化说明 | | 2025.03.16 | NewUI V2前端优化:
移除不必要内容,优化Local和CDN静态文件引入。

修复由于SQL类型大写导致无法转换的问题。(感谢@zzy-design的反馈)

JPA模板优化(感谢@PenroseYang的反馈):
修复不开启Lombok情况下Set/Get方法生成问题;
修复importDdate判断为true后没有引入日期类的问题
| diff --git a/generator-web/src/main/java/com/softdev/system/generator/service/GeneratorServiceImpl.java b/generator-web/src/main/java/com/softdev/system/generator/service/GeneratorServiceImpl.java index e6ec491..de98dbd 100644 --- a/generator-web/src/main/java/com/softdev/system/generator/service/GeneratorServiceImpl.java +++ b/generator-web/src/main/java/com/softdev/system/generator/service/GeneratorServiceImpl.java @@ -87,9 +87,14 @@ public class GeneratorServiceImpl implements GeneratorService { @Override public ClassInfo generateSelectSqlBySQLPraser(ParamInfo paramInfo) throws Exception { ClassInfo classInfo = new ClassInfo(); - Statement statement = CCJSqlParserUtil.parse(paramInfo.getTableSql()); + String processedSql = paramInfo.getTableSql().trim() + .replaceAll("'", "`") // 将单引号替换为反引号 + .replaceAll("\"", "`") // 将双引号替换为反引号 + .replaceAll(",", ","); // 将中文逗号替换为英文逗号 + + Statement statement = null; CCJSqlParserManager parserManager = new CCJSqlParserManager(); - statement = parserManager.parse(new StringReader(paramInfo.getTableSql())); + statement = parserManager.parse(new StringReader(processedSql)); TablesNamesFinder tablesNamesFinder = new TablesNamesFinder(); // 创建表名发现者对象 List tableNameList = tablesNamesFinder.getTableList(statement); // 获取到表名列表 //一般这里应该只解析到一个表名,除非多个表名,取第一个 @@ -97,7 +102,7 @@ public class GeneratorServiceImpl implements GeneratorService { String tableName = tableNameList.get(0).trim(); classInfo.setTableName(tableName); classInfo.setOriginTableName(tableName); - String className = StringUtilsPlus.upperCaseFirst(StringUtilsPlus.underlineToCamelCase(tableName)); + String className = StringUtilsPlus.upperCaseFirst(StringUtilsPlus.underlineToCamelCase(tableName)).replaceAll("`", ""); if (className.contains("_")) { className = className.replaceAll("_", ""); } @@ -114,7 +119,7 @@ public class GeneratorServiceImpl implements GeneratorService { List fieldList = new ArrayList(); selectItems.forEach(t->{ FieldInfo fieldInfo = new FieldInfo(); - String fieldName = ((Column)t.getExpression()).getColumnName(); + String fieldName = ((Column)t.getExpression()).getColumnName().replaceAll("`", ""); String aliasName = t.getAlias() != null ? t.getAlias().getName() : ((Column)t.getExpression()).getColumnName(); //存储原始字段名 fieldInfo.setFieldComment(aliasName);fieldInfo.setColumnName(aliasName); @@ -153,8 +158,14 @@ public class GeneratorServiceImpl implements GeneratorService { public ClassInfo generateCreateSqlBySQLPraser(ParamInfo paramInfo) throws Exception { ClassInfo classInfo = new ClassInfo(); Statement statement = null; + // 对SQL进行预处理,以提高解析成功率 + String processedSql = paramInfo.getTableSql().trim() + .replaceAll("'", "`") // 将单引号替换为反引号 + .replaceAll("\"", "`") // 将双引号替换为反引号 + .replaceAll(",", ","); // 将中文逗号替换为英文逗号 + try { - statement = CCJSqlParserUtil.parse(paramInfo.getTableSql().trim()); + statement = CCJSqlParserUtil.parse(processedSql); }catch (Exception e) { e.printStackTrace(); throw new SqlException("SQL语法错误:"+e.getMessage()); @@ -166,7 +177,7 @@ public class GeneratorServiceImpl implements GeneratorService { } // 提取表名 - String tableName = createTable.getTable().getName(); + String tableName = createTable.getTable().getName().replaceAll("`", ""); classInfo.setTableName(tableName); String className = StringUtilsPlus.upperCaseFirst(StringUtilsPlus.underlineToCamelCase(tableName)); if (className.contains("_")) { @@ -183,7 +194,7 @@ public class GeneratorServiceImpl implements GeneratorService { if (columnDefinitions != null) { for (ColumnDefinition columnDefinition : columnDefinitions) { FieldInfo fieldInfo = new FieldInfo(); - String columnName = columnDefinition.getColumnName(); + String columnName = columnDefinition.getColumnName().replaceAll("`", ""); fieldInfo.setColumnName(columnName); fieldInfo.setFieldComment(columnDefinition.toString()); diff --git a/generator-web/src/main/resources/application-bejson.yml b/generator-web/src/main/resources/application-bejson.yml index d56a6f5..079aaf5 100644 --- a/generator-web/src/main/resources/application-bejson.yml +++ b/generator-web/src/main/resources/application-bejson.yml @@ -53,11 +53,11 @@ OEM: header: SQL转Java JPA、MYBATIS实现类代码生成平台 keywords: sql转实体类,sql转DAO,SQL转service,SQL转JPA实现,SQL转MYBATIS实现 title: JAVA在线代码生成 - slogan: Free your hands from tedious and repetitive CRUD work - description:

SpringBootCodeGenerator,又名`大狼狗代码生成器`、`SQL转JAVA`、`SQL转JPA`、`SQL转Mybatis`、`Mybatis在线生成器`、`SQL转Java JPA、MYBATIS实现类代码生成平台`。

——从繁琐重复的`CRUD工作`中释放你的双手,可通过DDL SQL语句或Select SQL语句或简单Json -> 生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL/CommonMapper等相关模板代码。

+ slogan: 👐 Free your hands from boring CRUD—let the code write itself! ⚡ + description:

💻 SpringBootCodeGenerator,又名 `大狼狗代码生成器`🐺🐶,支持 SQL 一键转 JAVA/JPA/Mybatis/MybatisPlus 等多种模板,轻松搞定 CRUD,彻底解放双手 ✋!只需提供 DDL、SELECT SQL 或简单 JSON 👉 即可生成 生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL/CommonMapper 等代码模板。

🔥🔥🔥 全新 JSqlParser 引擎上线,强力支持 DDL CREATE SQL与 SELECT SQL 解析!欢迎体验 & 反馈 💬!

👨‍💻 面向开发者的高效利器,已服务数万工程师,欢迎 Star ⭐、Fork 🍴、提 Issue 💬,一起打造更强大的代码生成平台!

author: BEJSON.com packageName: www.bejson.com - copyright: Powered by Moshow + BeJSON , Might the holy light be with you ! + copyright: ✨ Powered by Moshow郑锴BeJSON — may the holy light guide your code, your coffee, and your commits! ⚡🧙‍♂️💻 returnUtilSuccess: ResponseUtil.success returnUtilFailure: ResponseUtil.error outputStr: www.bejson.com diff --git a/generator-web/src/main/resources/application-dev.yml b/generator-web/src/main/resources/application-dev.yml index 93c4bff..fdcf712 100644 --- a/generator-web/src/main/resources/application-dev.yml +++ b/generator-web/src/main/resources/application-dev.yml @@ -50,12 +50,12 @@ OEM: version: 2025 September header: SQL转Java JPA、MYBATIS实现类代码生成平台 keywords: sql转实体类,sql转DAO,SQL转service,SQL转JPA实现,SQL转MYBATIS实现 - title: JAVA代码生成平台 - slogan: Free your hands from tedious and repetitive CRUD work - description:

SpringBootCodeGenerator,又名`大狼狗代码生成器`、`SQL转JAVA`、`SQL转JPA`、`SQL转Mybatis`、`Mybatis在线生成器`、`SQL转Java JPA、MYBATIS实现类代码生成平台`。

——从繁琐重复的`CRUD工作`中释放你的双手,可通过DDL SQL语句或Select SQL语句或简单Json -> 生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL/CommonMapper等相关模板代码。

+ title: 大狼狗代码生成器 + slogan: 👐 Free your hands from boring CRUD—let the code write itself! ⚡ + description:

💻 SpringBootCodeGenerator,又名 `大狼狗代码生成器`🐺🐶,支持 SQL 一键转 JAVA/JPA/Mybatis/MybatisPlus 等多种模板,轻松搞定 CRUD,彻底解放双手 ✋!只需提供 DDL、SELECT SQL 或简单 JSON 👉 即可生成 生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL/CommonMapper 等代码模板。

🔥🔥🔥 全新 JSqlParser 引擎上线,强力支持 DDL CREATE SQL与 SELECT SQL 解析!欢迎体验 & 反馈 💬!

👨‍💻 面向开发者的高效利器,已服务数万工程师,欢迎 Star ⭐、Fork 🍴、提 Issue 💬,一起打造更强大的代码生成平台!

author: zhengkai.blog.csdn.net packageName: com.software.system - copyright: Powered by Moshow郑锴 , Might the holy light be with you ! + copyright: ✨ Powered by Moshow郑锴 — may the holy light guide your code, your coffee, and your commits! ⚡🧙‍♂️💻 returnUtilSuccess: ResponseUtil.success returnUtilFailure: ResponseUtil.error outputStr: http://zhengkai.blog.csdn.net diff --git a/generator-web/src/main/resources/application-json.yml b/generator-web/src/main/resources/application-json.yml index 4838be4..c1ccc0e 100644 --- a/generator-web/src/main/resources/application-json.yml +++ b/generator-web/src/main/resources/application-json.yml @@ -53,11 +53,11 @@ OEM: header: SQL转Java JPA、MYBATIS实现类代码生成平台 keywords: sql转实体类,sql转DAO,SQL转service,SQL转JPA实现,SQL转MYBATIS实现 title: JAVA在线代码生成 - slogan: Free your hands from tedious and repetitive CRUD work - description:

SpringBootCodeGenerator,又名`大狼狗代码生成器`、`SQL转JAVA`、`SQL转JPA`、`SQL转Mybatis`、`Mybatis在线生成器`、`SQL转Java JPA、MYBATIS实现类代码生成平台`。

——从繁琐重复的`CRUD工作`中释放你的双手,可通过DDL SQL语句或Select SQL语句或简单Json -> 生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL/CommonMapper等相关模板代码。

+ slogan: 👐 Free your hands from boring CRUD—let the code write itself! ⚡ + description:

💻 SpringBootCodeGenerator,又名 `大狼狗代码生成器`🐺🐶,支持 SQL 一键转 JAVA/JPA/Mybatis/MybatisPlus 等多种模板,轻松搞定 CRUD,彻底解放双手 ✋!只需提供 DDL、SELECT SQL 或简单 JSON 👉 即可生成 生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL/CommonMapper 等代码模板。

🔥🔥🔥 全新 JSqlParser 引擎上线,强力支持 DDL CREATE SQL与 SELECT SQL 解析!欢迎体验 & 反馈 💬!

👨‍💻 面向开发者的高效利器,已服务数万工程师,欢迎 Star ⭐、Fork 🍴、提 Issue 💬,一起打造更强大的代码生成平台!

author: https://www.json.cn/ packageName: www.json.cn - copyright: Powered by Moshow + JSON , Might the holy light be with you ! + copyright: ✨ Powered by Moshow郑锴JSON — may the holy light guide your code, your coffee, and your commits! ⚡🧙‍♂️💻 returnUtilSuccess: ResponseUtil.success returnUtilFailure: ResponseUtil.error outputStr: www.json.cn diff --git a/generator-web/src/main/resources/templates/newui2.html b/generator-web/src/main/resources/templates/newui2.html index a831a67..93f5ee7 100644 --- a/generator-web/src/main/resources/templates/newui2.html +++ b/generator-web/src/main/resources/templates/newui2.html @@ -62,7 +62,7 @@ ${(value.slogan)!!}