diff --git a/mybatis-flex-springboot3/pom.xml b/mybatis-flex-springboot3/pom.xml
index 8574488da7a551d970e590f29d37f56af9c3e479..d2a986898f0b5c0b5628dbce2c0e155ec1a53ee7 100644
--- a/mybatis-flex-springboot3/pom.xml
+++ b/mybatis-flex-springboot3/pom.xml
@@ -6,90 +6,67 @@
com.mybatis-flex.samples
mybatis-flex-springboot3
1.0-SNAPSHOT
-
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 3.4.1
+
+
17
17
-
- 1.8.2
- 8.0.27
-
- 6.0.7
- 3.0.4
- 2.0.7
- 5.0.1
-
-
- 4.13.2
-
-
com.mybatis-flex
mybatis-flex-spring-boot3-starter
- ${mybatis-flex.version}
+ 1.10.5
+
+
+ com.mybatis-flex
+ mybatis-flex-codegen
+ 1.10.1
+
+
+ com.mybatis-flex
+ mybatis-flex-processor
+ 1.10.5
+ provided
-
mysql
mysql-connector-java
- ${mysql.version}
+ 8.0.33
-
-
-
-
-
-
-
com.zaxxer
HikariCP
- ${HikariCP.version}
-
-
org.springframework.boot
spring-boot-starter
- ${spring-boot.version}
-
org.springframework.boot
spring-boot-starter-web
- ${spring-boot.version}
-
org.springframework
spring-context-support
- ${spring.version}
-
org.springframework.boot
spring-boot-autoconfigure
- ${spring-boot.version}
-
org.springframework
spring-jdbc
- ${spring.version}
-
org.springframework
spring-test
- ${spring.version}
-
-
-
-
@@ -98,8 +75,6 @@
${slf4j.version}
-
-
junit
@@ -107,11 +82,12 @@
${junit.version}
test
-
-
+
+ org.projectlombok
+ lombok
+ provided
+
-
-
@@ -129,21 +105,12 @@
target/generated-sources
-
org.apache.maven.plugins
maven-compiler-plugin
3.8.1
-
- 1.8
- 1.8
- UTF-8
-
-
-
-
\ No newline at end of file
diff --git a/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/Application.java b/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/Application.java
index c80972c7e3c404fd6a1212f5a661d113e087bff8..f4947cbc76c55809dd5f089bcfe6b54995580e9f 100644
--- a/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/Application.java
+++ b/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/Application.java
@@ -22,11 +22,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@MapperScan("com.mybatisflex.admin.mapper")
public class Application {
-
-
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
-
-
}
diff --git a/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/code/Codegen.java b/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/code/Codegen.java
new file mode 100644
index 0000000000000000000000000000000000000000..457b9d1abf5c09199e97d60f408a12dd34a4bf92
--- /dev/null
+++ b/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/code/Codegen.java
@@ -0,0 +1,89 @@
+package com.mybatisflex.admin.code;
+
+import com.mybatisflex.codegen.Generator;
+import com.mybatisflex.codegen.config.ColumnConfig;
+import com.mybatisflex.codegen.config.GlobalConfig;
+import com.zaxxer.hikari.HikariDataSource;
+
+public class Codegen {
+
+ public static void main(String[] args) {
+ //配置数据源
+ HikariDataSource dataSource = new HikariDataSource();
+ dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/mybatis-flex-dbtest?characterEncoding=utf-8");
+ dataSource.setUsername("root");
+ dataSource.setPassword("12345678");
+
+ //创建配置内容,两种风格都可以。
+ GlobalConfig globalConfig = createGlobalConfigUseStyle1();
+ //GlobalConfig globalConfig = createGlobalConfigUseStyle2();
+
+ //通过 datasource 和 globalConfig 创建代码生成器
+ Generator generator = new Generator(dataSource, globalConfig);
+
+ //生成代码
+ generator.generate();
+ }
+
+ public static GlobalConfig createGlobalConfigUseStyle1() {
+ //创建配置内容
+ GlobalConfig globalConfig = new GlobalConfig();
+
+ //设置根包
+ globalConfig.setBasePackage("com.test");
+
+ //设置表前缀和只生成哪些表
+ globalConfig.setTablePrefix("tb_");
+ globalConfig.setGenerateTable("article", "tb_account");
+
+ //设置生成 entity 并启用 Lombok
+ globalConfig.setEntityGenerateEnable(true);
+ globalConfig.setEntityWithLombok(true);
+ //设置项目的JDK版本,项目的JDK为14及以上时建议设置该项,小于14则可以不设置
+ globalConfig.setEntityJdkVersion(17);
+
+ //设置生成 mapper
+ globalConfig.setMapperGenerateEnable(true);
+
+ //可以单独配置某个列
+// ColumnConfig columnConfig = new ColumnConfig();
+// columnConfig.setColumnName("tenant_id");
+// columnConfig.setLarge(true);
+// columnConfig.setVersion(true);
+// globalConfig.setColumnConfig("tb_account", columnConfig);
+
+ return globalConfig;
+ }
+
+ public static GlobalConfig createGlobalConfigUseStyle2() {
+ //创建配置内容
+ GlobalConfig globalConfig = new GlobalConfig();
+
+ //设置根包
+ globalConfig.getPackageConfig()
+ .setBasePackage("com.test");
+
+ //设置表前缀和只生成哪些表,setGenerateTable 未配置时,生成所有表
+ globalConfig.getStrategyConfig()
+ .setTablePrefix("tb_")
+ .setGenerateTable("tb_account", "tb_account_session");
+
+ //设置生成 entity 并启用 Lombok
+ globalConfig.enableEntity()
+ .setWithLombok(true)
+ .setJdkVersion(17);
+
+ //设置生成 mapper
+ globalConfig.enableMapper();
+
+ //可以单独配置某个列
+ ColumnConfig columnConfig = new ColumnConfig();
+ columnConfig.setColumnName("tenant_id");
+ columnConfig.setLarge(true);
+ columnConfig.setVersion(true);
+ globalConfig.getStrategyConfig()
+ .setColumnConfig("tb_account", columnConfig);
+
+ return globalConfig;
+ }
+}
\ No newline at end of file
diff --git a/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/controller/AccountController.java b/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/controller/AccountController.java
index 3be78b9a325eb884e91dea3e4aef4fd9180669ef..909e2f6f3957e5a6090b1792c1f05aff07f8bcdc 100644
--- a/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/controller/AccountController.java
+++ b/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/controller/AccountController.java
@@ -17,6 +17,8 @@ package com.mybatisflex.admin.controller;
import com.mybatisflex.admin.mapper.AccountMapper;
import com.mybatisflex.admin.model.Account;
+import com.mybatisflex.core.paginate.Page;
+import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
@@ -47,4 +49,9 @@ public class AccountController {
account2.setBirthday(new Date());
accountMapper.insert(account2);
}
+
+ @GetMapping("/page")
+ Page page() {
+ return accountMapper.paginate(1,10,QueryWrapper.create().where(Account::getAge).gt(1));
+ }
}
diff --git a/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/mapper/ArticleMapper.java b/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/mapper/ArticleMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..46519f3cf1cf092db16cb9e6ea1aff4dbd8999c6
--- /dev/null
+++ b/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/mapper/ArticleMapper.java
@@ -0,0 +1,14 @@
+package com.mybatisflex.admin.mapper;
+
+import com.mybatisflex.core.BaseMapper;
+import com.mybatisflex.admin.model.Article;
+
+/**
+ * 文章 映射层。
+ *
+ * @author xcwang
+ * @since 2025-01-22
+ */
+public interface ArticleMapper extends BaseMapper {
+
+}
diff --git a/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/model/Account.java b/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/model/Account.java
index c144a77d7a0578f1622354fd58f66deecac46ef6..62feea62403bf2a4b86a86c29b552b5e5e6efca6 100644
--- a/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/model/Account.java
+++ b/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/model/Account.java
@@ -18,47 +18,16 @@ package com.mybatisflex.admin.model;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
+import lombok.Data;
import java.util.Date;
@Table("tb_account")
+@Data
public class Account {
-
@Id(keyType = KeyType.Auto)
private Long id;
private String userName;
private Integer age;
private Date birthday;
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- public Integer getAge() {
- return age;
- }
-
- public void setAge(Integer age) {
- this.age = age;
- }
-
- public Date getBirthday() {
- return birthday;
- }
-
- public void setBirthday(Date birthday) {
- this.birthday = birthday;
- }
}
diff --git a/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/model/Article.java b/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/model/Article.java
new file mode 100644
index 0000000000000000000000000000000000000000..90b5f6f885c2b5d0ff93b9c6057d0f348610e7b4
--- /dev/null
+++ b/mybatis-flex-springboot3/src/main/java/com/mybatisflex/admin/model/Article.java
@@ -0,0 +1,58 @@
+package com.mybatisflex.admin.model;
+
+import com.mybatisflex.annotation.Id;
+import com.mybatisflex.annotation.KeyType;
+import com.mybatisflex.annotation.Table;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+import java.io.Serial;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 文章 实体类。
+ *
+ * @author xcwang
+ * @since 2025-01-22
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@Table("article")
+public class Article implements Serializable {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * ID
+ */
+ @Id(keyType = KeyType.Auto)
+ private Long id;
+
+ /**
+ * 标题
+ */
+ private String title;
+
+ /**
+ * 内容
+ */
+ private String content;
+
+ /**
+ * 创建时间
+ */
+ private LocalDateTime createAt;
+
+ /**
+ * 创建者
+ */
+ private Long createBy;
+
+}
diff --git a/mybatis-flex-springboot3/src/main/resources/application.yml b/mybatis-flex-springboot3/src/main/resources/application.yml
index b7b68da0f177fed92795d947f566730327d0d1c7..1dfdd818df22f229505e658fcd708d649da446f6 100644
--- a/mybatis-flex-springboot3/src/main/resources/application.yml
+++ b/mybatis-flex-springboot3/src/main/resources/application.yml
@@ -2,6 +2,8 @@
spring:
datasource:
# driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://127.0.0.1:3306/dbtest
+ url: jdbc:mysql://127.0.0.1:3306/mybatis-flex-dbtest
username: root
- password: 123456
\ No newline at end of file
+ password: 12345678
+server:
+ port: 8081
\ No newline at end of file