Skip to content

Commit

Permalink
feat: release 2.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
huayanYu committed Sep 3, 2018
1 parent 03efa15 commit 3500a05
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v2.2.1

- 适配mybatis2.x版本

# v2.2.0

- 修复从默认数据源获取数据不能是组数据源的bug。
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ spring:

# 集成MybatisPlus

从2.1.0开始提供对mp3.0+的集成,在以前的版本你直接调用的方法是mp提供的内置方法,因其不是我们自己的方法不能切换数据源,你会得到一个NP异常。
从2.1.0开始提供对mp3.x的集成,在以前的版本你直接调用的方法是mp提供的内置方法,因其不是我们自己的方法不能切换数据源,你会得到一个NP异常。

从2.2.1开始提供对mp2.x的集成。

```yaml
spring:
Expand Down Expand Up @@ -335,7 +337,7 @@ public interface DynamicDataSourceProvider {

1. 多个库的事物如何处理?

处理不了,一个业务操作涉及多个库不要加事物。PS (如果能处理作者早就进BAT好了么)
**不能 不能 不能**,一个业务操作涉及多个库不要加事物。PS (如果能处理作者早就进BAT了)

2. 是否支持JPA?

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>2.2.0</version>
<version>2.2.1</version>
<packaging>jar</packaging>

<name>dynamic-datasource-spring-boot-starter</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
*/
package com.baomidou.dynamic.datasource.support;

import com.baomidou.mybatisplus.core.override.PageMapperProxy;
import lombok.extern.slf4j.Slf4j;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.ibatis.binding.MapperProxy;

import java.lang.reflect.Field;
import java.lang.reflect.Proxy;
Expand All @@ -28,13 +29,21 @@
* @author TaoYu
* @since 2.1.0
*/
@Slf4j
public class MybatisPlusResolver {

private static Field field;

static {
Class<?> proxyClass;
try {
field = PageMapperProxy.class.getDeclaredField("mapperInterface");
proxyClass = Class.forName("com.baomidou.mybatisplus.core.override");
} catch (ClassNotFoundException e) {
log.debug("未适配 mybatis-plus3");
proxyClass = MapperProxy.class;
}
try {
field = proxyClass.getDeclaredField("mapperInterface");
field.setAccessible(true);
} catch (NoSuchFieldException e) {
e.printStackTrace();
Expand Down

0 comments on commit 3500a05

Please sign in to comment.