diff --git a/README.md b/README.md
index ca8e7ae..d98e028 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
-#SSM集成的基础项目,项目使用Maven管理
+# SSM集成的基础项目,项目使用Maven管理
-#MyBatis3.3.0
+# MyBatis3.3.0
-#Spring[MVC]4.1.2.RELEASE
+# Spring[MVC]4.1.2.RELEASE
项目使用Spring4.1.2.RELEASE + SpringMVC4.1.2.RELEASE + Mybatis3.3.0
@@ -10,26 +10,68 @@
项目使用的mysql数据库,根据需要可以切换为其他数据库
-##Spring Boot集成MyBatis的基础项目
+集成分页插件 5.0.0 版本,注意配置变化:
+```xml
+
+
+
+
+ classpath:mapper/*.xml
+
+
+
+
+
+
+
+
+
+ helperDialect=mysql
+ reasonable=true
+ supportMethodsArguments=true
+ params=count=countSql
+ autoRuntimeDialect=true
+
+
+
+
+
+
+```
+- 拦截器 `com.github.pagehelper.PageInterceptor`
+- 原来的 `dialect` 变成了 `helperDialect`,这是基于 PageHelper 方式的分页
+- 具体变化看文档
-###https://github.com/abel533/MyBatis-Spring-Boot
+## 新书《MyBatis 从入门到精通》
-##MyBatis工具
+
-###http://www.mybatis.tk
+预售地址:[京东](https://item.jd.com/12103309.html),[当当](http://product.dangdang.com/25098208.html),[亚马逊](https://www.amazon.cn/MyBatis从入门到精通-刘增辉/dp/B072RC11DM/ref=sr_1_18?ie=UTF8&qid=1498007125&sr=8-18&keywords=mybatis)
-##推荐使用Mybatis通用Mapper3
+CSDN博客:http://blog.csdn.net/isea533/article/details/73555400
-###https://github.com/abel533/Mapper
+GitHub项目:https://github.com/mybatis-book/book
-##推荐使用Mybatis分页插件PageHelper
+## Spring Boot集成MyBatis的基础项目
-###https://github.com/pagehelper/Mybatis-PageHelper
+### https://github.com/abel533/MyBatis-Spring-Boot
-##作者信息
+## MyBatis工具
+
+### http://www.mybatis.tk
+
+## 推荐使用Mybatis通用Mapper3
+
+### https://github.com/abel533/Mapper
+
+## 推荐使用Mybatis分页插件PageHelper
+
+### https://github.com/pagehelper/Mybatis-PageHelper
+
+## 作者信息
- 作者博客:http://blog.csdn.net/isea533
- 作者邮箱:abel533@gmail.com
-- Mybatis工具群: 211286137 (Mybatis相关工具插件等等)
+- 如需加群,请通过 http://mybatis.tk 首页按钮加群。
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 19c7b4e..4166eda 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,23 +11,15 @@
UTF-8
-
-
- ${basedir}/src/main/java
- com.isea533.mybatis.mapper
- com.isea533.mybatis.model
-
- ${basedir}/src/main/resources
- mapper
1.6
- 3.3.1
- 3.3.6
- 4.1.4
+ 3.4.6
+ 4.0.3
+ 5.1.4
5.1.29
4.1.2.RELEASE
- 1.2.4
+ 1.3.2
@@ -265,7 +257,7 @@
org.mybatis.generator
mybatis-generator-maven-plugin
- 1.3.2
+ 1.3.6
${basedir}/src/main/resources/generator/generatorConfig.xml
true
diff --git a/src/main/java/com/isea533/mybatis/filter/MapperBeanDefinitionRegistryPostProcessor.java b/src/main/java/com/isea533/mybatis/filter/MapperBeanDefinitionRegistryPostProcessor.java
new file mode 100644
index 0000000..ab979fb
--- /dev/null
+++ b/src/main/java/com/isea533/mybatis/filter/MapperBeanDefinitionRegistryPostProcessor.java
@@ -0,0 +1,40 @@
+package com.isea533.mybatis.filter;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
+import org.springframework.core.Ordered;
+import tk.mybatis.mapper.common.Mapper;
+
+/**
+ * @author liuzh
+ * @since 2017/11/4.
+ */
+public class MapperBeanDefinitionRegistryPostProcessor implements BeanDefinitionRegistryPostProcessor, Ordered {
+ private BeanDefinitionRegistry registry;
+
+ @Override
+ public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
+ System.out.println("postProcessBeanDefinitionRegistry");
+ this.registry = registry;
+ }
+
+ @Override
+ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
+ System.out.println("postProcessBeanFactory");
+
+ String[] names = beanFactory.getBeanNamesForType(Mapper.class);
+ for (String name : names) {
+ BeanDefinition beanDefinition = beanFactory.getBeanDefinition(name);
+ System.out.println(beanDefinition.getBeanClassName());
+ }
+
+ }
+
+ @Override
+ public int getOrder() {
+ return HIGHEST_PRECEDENCE;
+ }
+}
diff --git a/src/main/java/com/isea533/mybatis/filter/MapperFilter.java b/src/main/java/com/isea533/mybatis/filter/MapperFilter.java
new file mode 100644
index 0000000..da3e208
--- /dev/null
+++ b/src/main/java/com/isea533/mybatis/filter/MapperFilter.java
@@ -0,0 +1,34 @@
+package com.isea533.mybatis.filter;
+
+import com.isea533.mybatis.mapper.CountryMapper;
+import com.isea533.mybatis.model.Country;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.servlet.*;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * @author liuzh
+ * @since 2017/10/8.
+ */
+public class MapperFilter implements Filter {
+ @Autowired
+ private CountryMapper countryMapper;
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException {
+ System.out.println("init");
+ }
+
+ @Override
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
+ List countries = countryMapper.selectAll();
+ filterChain.doFilter(servletRequest, servletResponse);
+ }
+
+ @Override
+ public void destroy() {
+ System.out.println("destroy");
+ }
+}
diff --git a/src/main/java/com/isea533/mybatis/mapper/CountryMapper.java b/src/main/java/com/isea533/mybatis/mapper/CountryMapper.java
index 6b9b997..d8b9bbf 100644
--- a/src/main/java/com/isea533/mybatis/mapper/CountryMapper.java
+++ b/src/main/java/com/isea533/mybatis/mapper/CountryMapper.java
@@ -1,32 +1,7 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2014 abel533@gmail.com
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
package com.isea533.mybatis.mapper;
import com.isea533.mybatis.model.Country;
-import com.isea533.mybatis.util.MyMapper;
-
-public interface CountryMapper extends MyMapper {
+import tk.mybatis.mapper.common.Mapper;
+public interface CountryMapper extends Mapper {
}
\ No newline at end of file
diff --git a/src/main/java/com/isea533/mybatis/model/Country.java b/src/main/java/com/isea533/mybatis/model/Country.java
index 12835ff..8f14acd 100644
--- a/src/main/java/com/isea533/mybatis/model/Country.java
+++ b/src/main/java/com/isea533/mybatis/model/Country.java
@@ -1,41 +1,15 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2014 abel533@gmail.com
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
package com.isea533.mybatis.model;
-import javax.persistence.Column;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
+import javax.persistence.*;
+@Table(name = "country")
public class Country {
/**
* 主键
*/
@Id
@Column(name = "Id")
- @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @GeneratedValue(generator = "JDBC")
private Integer id;
/**
diff --git a/src/main/resources/applicationContext.xml b/src/main/resources/applicationContext.xml
index fbaa2b4..bfe02da 100644
--- a/src/main/resources/applicationContext.xml
+++ b/src/main/resources/applicationContext.xml
@@ -73,11 +73,11 @@
-
+
- dialect=mysql
+ helperDialect=mysql
reasonable=true
supportMethodsArguments=true
params=count=countSql
@@ -91,15 +91,6 @@
-
-
-
@@ -125,4 +116,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/config.properties b/src/main/resources/config.properties
index 92559c2..9914238 100644
--- a/src/main/resources/config.properties
+++ b/src/main/resources/config.properties
@@ -24,7 +24,7 @@
# \u6570\u636E\u5E93\u914D\u7F6E
jdbc.driverClass = com.mysql.jdbc.Driver
-jdbc.url = jdbc:mysql://192.168.16.137:3306/test
+jdbc.url = jdbc:mysql://localhost:3306/test
jdbc.user = root
jdbc.password =
@@ -32,8 +32,4 @@ jdbc.password =
jdbc.maxPoolSize=50
jdbc.minPoolSize=10
jdbc.maxStatements=100
-jdbc.testConnection=true
-
-# \u901A\u7528Mapper\u914D\u7F6E
-mapper.plugin = tk.mybatis.mapper.generator.MapperPlugin
-mapper.Mapper = tk.mybatis.mapper.common.Mapper
\ No newline at end of file
+jdbc.testConnection=true
\ No newline at end of file
diff --git a/src/main/resources/generator/generatorConfig.xml b/src/main/resources/generator/generatorConfig.xml
index b69ba60..fb2b4a9 100644
--- a/src/main/resources/generator/generatorConfig.xml
+++ b/src/main/resources/generator/generatorConfig.xml
@@ -29,30 +29,32 @@
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
-
+
-
-
-
-
-
-
-
+
+
+
-
-
+
+
+
+
-
+
+
-
+
-
+
-
-
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/mapper/CountryMapper.xml b/src/main/resources/mapper/CountryMapper.xml
index 4d718ae..73de6fa 100644
--- a/src/main/resources/mapper/CountryMapper.xml
+++ b/src/main/resources/mapper/CountryMapper.xml
@@ -1,37 +1,13 @@
-
-
-
-
-
-
+
+
+
+
-
-
-
+
+
+