diff --git a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/RowTestStarter.java b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/RowTestStarter.java
index b0cae942..db4266d1 100644
--- a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/RowTestStarter.java
+++ b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/RowTestStarter.java
@@ -16,10 +16,11 @@
package com.mybatisflex.test;
import com.mybatisflex.core.MybatisFlexBootstrap;
+import com.mybatisflex.core.audit.AuditManager;
+import com.mybatisflex.core.audit.ConsoleMessageCollector;
import com.mybatisflex.core.row.Row;
import com.mybatisflex.core.row.RowKey;
import com.mybatisflex.core.row.RowMapper;
-import org.apache.ibatis.logging.stdout.StdOutImpl;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
@@ -37,9 +38,12 @@ public class RowTestStarter {
MybatisFlexBootstrap bootstrap = MybatisFlexBootstrap.getInstance()
.setDataSource(dataSource)
- .setLogImpl(StdOutImpl.class)
+// .setLogImpl(StdOutImpl.class)
.start();
+ AuditManager.setAuditEnable(true);
+ AuditManager.setMessageCollector(new ConsoleMessageCollector());
+
//查询 ID 为 1 的数据
Row row = bootstrap.execute(RowMapper.class, rowMapper ->
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/pom.xml b/mybatis-flex-test/mybatis-flex-spring-boot-test/pom.xml
index b8244474..4115f540 100644
--- a/mybatis-flex-test/mybatis-flex-spring-boot-test/pom.xml
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/pom.xml
@@ -5,7 +5,7 @@
mybatis-flex-test
com.mybatis-flex
- 1.0.7
+ 1.0.8
4.0.0
@@ -21,12 +21,7 @@
com.mybatis-flex
mybatis-flex-spring-boot-starter
- 1.0.7
-
-
-
- org.springframework.boot
- spring-boot-starter
+ 1.0.8
@@ -34,38 +29,48 @@
spring-boot-starter-web
+
+
+
+
+
+
+
+
+
+
+
- org.springframework
- spring-jdbc
+ org.springframework.boot
+ spring-boot-starter-data-jdbc
com.h2database
h2
- 1.4.199
+ 2.1.214
+
+
+
+
+
+
- org.yaml
- snakeyaml
- 1.33
-
-
-
-
- org.springframework
- spring-test
+ org.springframework.boot
+ spring-boot-starter-test
test
-
- junit
- junit
- test
-
+
+
+
+
+
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/SampleApplication.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/SampleApplication.java
index 3c315b76..411b777b 100644
--- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/SampleApplication.java
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/SampleApplication.java
@@ -15,25 +15,22 @@
*/
package com.mybatisflex.test;
-import com.mybatisflex.test.mapper.AccountMapper;
-import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
-@MapperScan("com.mybatisflex.test.mapper")
+//@MapperScan("com.mybatisflex.test.mapper")
public class SampleApplication implements CommandLineRunner {
- @Autowired
- private AccountMapper accountMapper;
+// @Resource
+// private AccountMapper accountMapper;
@Override
public void run(String... args) throws Exception {
- System.out.println(this.accountMapper.selectOneById(1));
+// System.out.println(this.accountMapper.selectOneById(1));
}
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/controller/AccountController.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/controller/AccountController.java
index 1ce2cee3..c0af6262 100644
--- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/controller/AccountController.java
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/controller/AccountController.java
@@ -1,60 +1,60 @@
-/**
- * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.mybatisflex.test.controller;
-
-import com.mybatisflex.core.paginate.Page;
-import com.mybatisflex.core.query.QueryWrapper;
-import com.mybatisflex.test.mapper.AccountMapper;
-import com.mybatisflex.test.model.Account;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-
-@RestController
-public class AccountController {
-
- @Autowired
- AccountMapper accountMapper;
-
-
- @PostMapping("/account/add")
- String add(@RequestBody Account account){
- accountMapper.insert(account);
- return "add ok!";
- }
-
-
- @GetMapping("/account/{id}")
- Account selectOne(@PathVariable("id") Long id) {
- return accountMapper.selectOneById(id);
- }
-
-
- @GetMapping("/selectListByIds/{id}")
- List selectListByIds(@PathVariable("id") String id) {
- List ids = Arrays.stream(id.split(",")).mapToLong(Long::parseLong).boxed().collect(Collectors.toList());
- return accountMapper.selectListByIds(ids);
- }
-
-
- @GetMapping("/paginate")
- Page paginate(@RequestParam(defaultValue = "1") int pageNumber, @RequestParam(defaultValue = "10") int pageSize) {
- return accountMapper.paginate(pageNumber,pageSize, QueryWrapper.create());
- }
-}
+///**
+// * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
+// *
+// * Licensed under the Apache License, Version 2.0 (the "License");
+// * you may not use this file except in compliance with the License.
+// * You may obtain a copy of the License at
+// *
+// * http://www.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing, software
+// * distributed under the License is distributed on an "AS IS" BASIS,
+// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// * See the License for the specific language governing permissions and
+// * limitations under the License.
+// */
+//package com.mybatisflex.test.controller;
+//
+//import com.mybatisflex.core.paginate.Page;
+//import com.mybatisflex.core.query.QueryWrapper;
+//import com.mybatisflex.test.mapper.AccountMapper;
+//import com.mybatisflex.test.model.Account;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.web.bind.annotation.*;
+//
+//import java.util.Arrays;
+//import java.util.List;
+//import java.util.stream.Collectors;
+//
+//@RestController
+//public class AccountController {
+//
+// @Autowired
+// AccountMapper accountMapper;
+//
+//
+// @PostMapping("/account/add")
+// String add(@RequestBody Account account){
+// accountMapper.insert(account);
+// return "add ok!";
+// }
+//
+//
+// @GetMapping("/account/{id}")
+// Account selectOne(@PathVariable("id") Long id) {
+// return accountMapper.selectOneById(id);
+// }
+//
+//
+// @GetMapping("/selectListByIds/{id}")
+// List selectListByIds(@PathVariable("id") String id) {
+// List ids = Arrays.stream(id.split(",")).mapToLong(Long::parseLong).boxed().collect(Collectors.toList());
+// return accountMapper.selectListByIds(ids);
+// }
+//
+//
+// @GetMapping("/paginate")
+// Page paginate(@RequestParam(defaultValue = "1") int pageNumber, @RequestParam(defaultValue = "10") int pageSize) {
+// return accountMapper.paginate(pageNumber,pageSize, QueryWrapper.create());
+// }
+//}
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Account.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Account.java
index a98d14e1..d5b8dcde 100644
--- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Account.java
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/Account.java
@@ -21,7 +21,7 @@ import com.mybatisflex.annotation.KeyType;
import java.util.Date;
-@Table("tb_account")
+@Table(value = "tb_account",onSet = AccountOnSetListener.class)
public class Account {
@Id(keyType = KeyType.Auto)
@@ -30,6 +30,8 @@ public class Account {
private Integer age;
private Date birthday;
+
+
public Long getId() {
return id;
}
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/AccountOnSetListener.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/AccountOnSetListener.java
new file mode 100644
index 00000000..a09fa49f
--- /dev/null
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/model/AccountOnSetListener.java
@@ -0,0 +1,11 @@
+package com.mybatisflex.test.model;
+
+import com.mybatisflex.annotation.SetListener;
+
+public class AccountOnSetListener implements SetListener {
+ @Override
+ public Object onSet(Object entity, String property, Object value) {
+ System.out.println(">>>>>>> property: " + property +" value:" + value);
+ return value;
+ }
+}
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml
index 99e72bba..b8e00b13 100644
--- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml
@@ -1,12 +1,14 @@
# DataSource Config
spring:
+ h2:
+ console:
+ enabled: true
datasource:
+ url: jdbc:h2:mem:testdb
driver-class-name: org.h2.Driver
- schema: classpath:schema.sql
- username: root
- password: test
+ username: sa
+ password:
sql:
init:
schema-locations: classpath:schema.sql
- data-locations: classpath:data.sql
- mybatis-flex:
\ No newline at end of file
+ data-locations: classpath:data.sql
\ No newline at end of file
diff --git a/mybatis-flex-test/mybatis-flex-spring-test/pom.xml b/mybatis-flex-test/mybatis-flex-spring-test/pom.xml
index 309ed067..5d7dc744 100644
--- a/mybatis-flex-test/mybatis-flex-spring-test/pom.xml
+++ b/mybatis-flex-test/mybatis-flex-spring-test/pom.xml
@@ -5,7 +5,7 @@
mybatis-flex-test
com.mybatis-flex
- 1.0.7
+ 1.0.8
4.0.0
@@ -20,13 +20,13 @@
com.mybatis-flex
mybatis-flex-core
- 1.0.7
+ 1.0.8
com.mybatis-flex
mybatis-flex-spring
- 1.0.7
+ 1.0.8
diff --git a/mybatis-flex-test/mybatis-flex-spring-test/src/main/java/com/mybatisflex/test/model/Account.java b/mybatis-flex-test/mybatis-flex-spring-test/src/main/java/com/mybatisflex/test/model/Account.java
index 628056aa..72f2cc92 100644
--- a/mybatis-flex-test/mybatis-flex-spring-test/src/main/java/com/mybatisflex/test/model/Account.java
+++ b/mybatis-flex-test/mybatis-flex-spring-test/src/main/java/com/mybatisflex/test/model/Account.java
@@ -20,7 +20,7 @@ import com.mybatisflex.annotation.Table;
import java.util.Date;
-@Table("tb_account")
+@Table(value = "tb_account", onSet = AccountOnSetListener.class)
public class Account {
@Id
@@ -60,4 +60,14 @@ public class Account {
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
+
+ @Override
+ public String toString() {
+ return "Account{" +
+ "id=" + id +
+ ", userName='" + userName + '\'' +
+ ", age=" + age +
+ ", birthday=" + birthday +
+ '}';
+ }
}
diff --git a/mybatis-flex-test/mybatis-flex-spring-test/src/main/java/com/mybatisflex/test/model/AccountOnSetListener.java b/mybatis-flex-test/mybatis-flex-spring-test/src/main/java/com/mybatisflex/test/model/AccountOnSetListener.java
new file mode 100644
index 00000000..a09fa49f
--- /dev/null
+++ b/mybatis-flex-test/mybatis-flex-spring-test/src/main/java/com/mybatisflex/test/model/AccountOnSetListener.java
@@ -0,0 +1,11 @@
+package com.mybatisflex.test.model;
+
+import com.mybatisflex.annotation.SetListener;
+
+public class AccountOnSetListener implements SetListener {
+ @Override
+ public Object onSet(Object entity, String property, Object value) {
+ System.out.println(">>>>>>> property: " + property +" value:" + value);
+ return value;
+ }
+}
diff --git a/mybatis-flex-test/pom.xml b/mybatis-flex-test/pom.xml
index 17b06ed6..0348fdc3 100644
--- a/mybatis-flex-test/pom.xml
+++ b/mybatis-flex-test/pom.xml
@@ -5,7 +5,7 @@
parent
com.mybatis-flex
- 1.0.7
+ 1.0.8
4.0.0
diff --git a/pom.xml b/pom.xml
index b38caaa7..03dbc216 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
com.mybatis-flex
parent
pom
- 1.0.7
+ 1.0.8
mybatis-flex
https://mybatis-flex.com
@@ -137,6 +137,18 @@
${spring-boot.version}
+
+ org.springframework.boot
+ spring-boot-starter-data-jdbc
+ ${spring-boot.version}
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ ${spring-boot.version}
+
+
junit