diff --git a/README.md b/README.md
index 57c9f968622566de3c854a00c23ecd24b682ff96..10045ee5fe7b697d60f6e7afc1550af5e5223494 100644
--- a/README.md
+++ b/README.md
@@ -14,12 +14,12 @@ springboot-mybatis-wr-separation is a Maven project based on SpringBoot and Myba
com.gitee.sunchenbin
springboot-mybatis-wr-separation
- 0.0.1.RELEASE
+ 0.0.3.RELEASE
2. application.properties中需要做如下配置
- (1) mybatis的配置
+ (1) mybatis的配置(根据自己的配置来)
mybatis.mapperLocations=classpath:sql-mapper/**/*.xml
mybatis.typeAliasesPackage=com.xxx.api.xxx.model,com.xxx.api.xxx.command
@@ -33,16 +33,17 @@ springboot-mybatis-wr-separation is a Maven project based on SpringBoot and Myba
spring.datasource.read.username=root
spring.datasource.read.password=123456
spring.datasource.read.driver-class-name=org.postgresql.Driver
+
+ (3) 读写分离切点的expression表达式(建议切manager或者service)
+ wr.separation.pointcut.expression=execution(public * com.xxx..*.*(..))
3. 应用插件的springboot项目需要配置扫码插件的包,即@ComponentScan需要配置对"com.gitee.sunshine.*"包路径的扫描
#### 使用说明
-1. 本插件提供两个注解,@WriteDB(走写库)、@ReadDB(走读库)
+1. 本插件提供一个注解,@ReadDB(走读库),如果不打注解默认走写库
2. 注解适用范围,必须是spring管理的bean的方法,注解不支持打在接口方法上,通常来说建议在manager层service层的方法上使用
-3. 注解生命周期,作用于当前线程,如果当前线程的,有任意一个地方设置了@WriteDB或者@ReadDB,那么本线程之后都以此设置作为数据源,这是为了避免来回切换导致的事务问题,如果整个线程没有设置这个注解,那么默认使用写库。
-
-4. 如果整个线程里执行的方法都没有打这两个注解中的任意一个,那么默认走写库。
+3. 注解生命周期,为了避免读库写库来回切换,产生的事务问题,这里规定,当前线程只会使用一个库去执行操作,比如a.test1()被调用时,首先a是被spring管理的类,并且他在我们配置文件“读写分离切点表达式”的范围内,那么此时,如果test1()打了注解@ReadDB,那么从此开始直到这个线程结束了,都使用读库,如果没有打注解,那么从此开始知道整个线程结束了都使用写库。
diff --git a/pom.xml b/pom.xml
index 9b2131c803da8bf808a5606805f726e05a4be2a7..6531d9f0078c64b394a450dc2ae9c4e1db1e6d8d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.gitee.sunchenbin
springboot-mybatis-wr-separation
- 0.0.2.RELEASE
+ 0.0.3.RELEASE
jar
diff --git a/src/main/java/com/gitee/sunshine/factory/StackContext.java b/src/main/java/com/gitee/sunshine/factory/StackContext.java
index a303e42e5002cfe327f78722b2e81c5df6972bc7..154dd81cb66d512c6f663322a941577767227437 100644
--- a/src/main/java/com/gitee/sunshine/factory/StackContext.java
+++ b/src/main/java/com/gitee/sunshine/factory/StackContext.java
@@ -12,7 +12,7 @@ public class StackContext implements ServiceInvocationContext {
public static final String TRANSACTIONID_FORMAT_STRING = "%s-%s-%s";
- private Stack invocationStatusStack = new Stack<>();
+ private Stack invocationStatusStack = new Stack();
@Override
public InvocationStatus createInvocation(MethodInvocation invocation) {
@@ -44,7 +44,7 @@ public class StackContext implements ServiceInvocationContext {
@Override
public void clean() {
- this.invocationStatusStack = new Stack<>();
+ this.invocationStatusStack = new Stack();
}
private String createTransactionId() {