可以连表生成文件,但是不正确

This commit is contained in:
2025-10-21 23:51:55 +08:00
parent cd421afc6c
commit 6e76d30bac
28 changed files with 2131 additions and 604 deletions

View File

@@ -0,0 +1,88 @@
server:
port: 8080
undertow:
# 设置IO线程数, 它主要执行非阻塞的任务, 它们会负责多个连接
io-threads: 4
# 阻塞任务线程池, 当执行类似servlet请求阻塞操作, undertow会从这个线程池中取得线程
worker-threads: 20
# 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理
buffer-size: 1024
# 是否分配的直接内存
direct-buffers: true
# 数据库配置
datasource:
url: jdbc:mysql://192.168.0.107:3306/globalVoice?characterEncoding=utf8&useUnicode=true&useSSL=false&allowPublicKeyRetrieval=true
username: intasect
password: 2$hGv1Dz[3)J7]BS]
driver-class-name: com.mysql.cj.jdbc.Driver
# 生成配置信息
generate:
# 生成模式hibernate,jpa,mybatis,mybatis-plus
mode: mybatis-plus
# 生成代码模式 file(直接在指定目录下生成代码),coding(在目录下生成/src/main/java和对应的package路径)
type: coding
# 输出目录
out: C:/0110_Workspace/yexuejc/db2java/export
# 包名
package: com.yexuejc.db2java.export
# 作者
author: yexuejc
# lombok模式 - 启用后不生成getter/setter方法使用@Data注解
lombok: false
# merge模式 - 是否合并已存在的文件
merge: true
# 覆盖已存在文件
override: true
# 模板引擎freemarker,velocity,beetl,enjoy
engine: freemarker
# 忽略表
ignore-table:
- sys_user
- sys_role
- sys_role_user
# 忽略字段
ignore-column:
- create_time
- update_time
# 包含表
include-table:
- sys_user
- sys_role
- sys_role_user
# 实体类配置
entity:
# 是否生成序列化版本ID
serialVersionUID: true
# 是否使用Serial注解(Java 14+)
serialAnnotation: false
# 是否生成字段常量
columnConstant: false
# 是否启用链式模型(返回this)
chainModel: false
# 是否生成toString方法(lombok=false时有效)
toString: true
# 是否使用JavaDoc注释字段
fieldUseJavaDoc: true
# 是否启用ActiveRecord模式
activeRecord: false
# 是否实现Serializable接口
serializable: true
# 是否生成equals和hashCode方法
equalsAndHashCode: false
# 字段命名策略: camelCase(驼峰), underline(下划线)
fieldNaming: camelCase
# 表名注解策略: none(无注解), table(使用@Table), entity(使用@Entity)
tableAnnotation: none
controller:
# 驼峰转连字符(默认 false
## <code>@RequestMapping("/managerUserActionHistory")</code> -> <code>@RequestMapping("/manager-user-action-history")</code>
mappingHyphen: true
# 生成 <code>@RestController</code> 控制器(默认 false
## <code>@Controller</code> -> <code>@RestController</code>
restStyle: true
# 自定义继承的Controller类全称带包名,默认为空
## superClass: com.yexuejc.db2java.export.controller.BaseController
superClass:

View File

@@ -0,0 +1,179 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DB2Java代码生成器</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container mt-5">
<h1 class="mb-4">DB2Java代码生成器</h1>
<!-- 显示成功或错误消息 -->
<div th:if="${success}" class="alert alert-success alert-dismissible fade show" role="alert">
<span th:text="${success}"></span>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<div th:if="${error}" class="alert alert-danger alert-dismissible fade show" role="alert">
<span th:text="${error}"></span>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<form action="/generate" method="post">
<div class="card mb-4">
<div class="card-header">
<h5>数据库配置</h5>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-6 mb-3">
<label for="url" class="form-label">数据库URL</label>
<input type="text" class="form-control" id="url" name="url"
th:value="${dataSourceProperties.url}" required>
</div>
<div class="col-md-6 mb-3">
<label for="driverClassName" class="form-label">驱动类名</label>
<input type="text" class="form-control" id="driverClassName" name="driverClassName"
th:value="${dataSourceProperties.driverClassName}" required>
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="username" class="form-label">用户名</label>
<input type="text" class="form-control" id="username" name="username"
th:value="${dataSourceProperties.username}" required>
</div>
<div class="col-md-6 mb-3">
<label for="password" class="form-label">密码</label>
<input type="password" class="form-control" id="password" name="password"
th:value="${dataSourceProperties.password}" required>
</div>
</div>
</div>
</div>
<div class="card mb-4">
<div class="card-header">
<h5>生成配置</h5>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-6 mb-3">
<label for="mode" class="form-label">生成模式</label>
<select class="form-select" id="mode" name="mode" required>
<option value="hibernate" th:selected="${generateProperties.mode == 'hibernate'}">
Hibernate
</option>
<option value="jpa" th:selected="${generateProperties.mode == 'jpa'}">JPA</option>
<option value="mybatis" th:selected="${generateProperties.mode == 'mybatis'}">MyBatis
</option>
<option value="mybatis-plus" th:selected="${generateProperties.mode == 'mybatis-plus'}">
MyBatis-Plus
</option>
</select>
</div>
<div class="col-md-6 mb-3">
<label for="type" class="form-label">生成代码模式</label>
<select class="form-select" id="type" name="type" required>
<option value="file" th:selected="${generateProperties.type == 'file'}">File</option>
<option value="coding" th:selected="${generateProperties.type == 'coding'}">Coding</option>
</select>
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="out" class="form-label">输出目录</label>
<input type="text" class="form-control" id="out" name="out"
th:value="${generateProperties.out}" required>
</div>
<div class="col-md-6 mb-3">
<label for="packageName" class="form-label">包名</label>
<input type="text" class="form-control" id="packageName" name="packageName"
th:value="${generateProperties.packageName}" required>
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="author" class="form-label">作者</label>
<input type="text" class="form-control" id="author" name="author"
th:value="${generateProperties.author}">
</div>
<div class="col-md-6 mb-3">
<label for="engine" class="form-label">模板引擎</label>
<select class="form-select" id="engine" name="engine" required>
<option value="freemarker" th:selected="${generateProperties.engine == 'freemarker'}">
FreeMarker
</option>
<option value="velocity" th:selected="${generateProperties.engine == 'velocity'}">Velocity
</option>
<option value="beetl" th:selected="${generateProperties.engine == 'beetl'}">Beetl</option>
<option value="enjoy" th:selected="${generateProperties.engine == 'enjoy'}">Enjoy</option>
</select>
</div>
</div>
<div class="row">
<div class="col-md-3 mb-3">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="lombok" name="lombok"
th:checked="${generateProperties.lombok}">
<label class="form-check-label" for="lombok">启用Lombok</label>
</div>
</div>
<div class="col-md-3 mb-3">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="merge" name="merge"
th:checked="${generateProperties.merge}">
<label class="form-check-label" for="merge">合并模式</label>
</div>
</div>
<div class="col-md-3 mb-3">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="override" name="override"
th:checked="${generateProperties.override}">
<label class="form-check-label" for="override">覆盖文件</label>
</div>
</div>
</div>
</div>
</div>
<div class="card mb-4">
<div class="card-header">
<h5>表和字段配置</h5>
</div>
<div class="card-body">
<div class="mb-3">
<label for="includeTable" class="form-label">包含表(每行一个)</label>
<textarea class="form-control" id="includeTable" name="includeTable" rows="3"
th:text="${generateProperties?.includeTable != null ? #strings.listJoin(generateProperties.includeTable, separator) : ''}">
</textarea>
</div>
<div class="mb-3">
<label for="ignoreTable" class="form-label">忽略表(每行一个)</label>
<textarea class="form-control" id="ignoreTable" name="ignoreTable" rows="3"
th:text="${generateProperties?.ignoreTable != null ? #strings.listJoin(generateProperties.ignoreTable, separator) : ''}"></textarea>
</div>
<div class="mb-3">
<label for="ignoreColumn" class="form-label">忽略字段(每行一个)</label>
<textarea class="form-control" id="ignoreColumn" name="ignoreColumn" rows="3"
th:text="${generateProperties?.ignoreColumn != null ? #strings.listJoin(generateProperties.ignoreColumn, separator) : ''}"></textarea>
</div>
</div>
</div>
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
<button type="submit" class="btn btn-primary btn-lg">生成代码</button>
</div>
</form>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>