From c2882dc9c9a88636eaadceddc52f854d180fa983 Mon Sep 17 00:00:00 2001
From: Suomm <1474983351@qq.com>
Date: Wed, 28 Jun 2023 10:06:02 +0800
Subject: [PATCH 01/17] =?UTF-8?q?style:=20=E6=B7=BB=E5=8A=A0=20MybatisAdap?=
=?UTF-8?q?terFactoryFlex=20=E6=B3=A8=E9=87=8A=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../MybatisAdapterFactoryFlex.java | 24 ++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/integration/MybatisAdapterFactoryFlex.java b/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/integration/MybatisAdapterFactoryFlex.java
index 1c2376b9..d331e4e4 100644
--- a/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/integration/MybatisAdapterFactoryFlex.java
+++ b/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/integration/MybatisAdapterFactoryFlex.java
@@ -1,17 +1,34 @@
+/*
+ * 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.solon.integration;
-import org.noear.solon.core.BeanWrap;
-import org.noear.solon.core.Props;
import org.apache.ibatis.solon.MybatisAdapter;
import org.apache.ibatis.solon.MybatisAdapterFactory;
+import org.noear.solon.core.BeanWrap;
+import org.noear.solon.core.Props;
/**
- * 适配器工厂 for mybatis-flex
+ * MyBatis-Flex 适配器工厂。
*
* @author noear
* @since 2.2
*/
public class MybatisAdapterFactoryFlex implements MybatisAdapterFactory {
+
@Override
public MybatisAdapter create(BeanWrap dsWrap) {
return new MybatisAdapterFlex(dsWrap);
@@ -21,4 +38,5 @@ public class MybatisAdapterFactoryFlex implements MybatisAdapterFactory {
public MybatisAdapter create(BeanWrap dsWrap, Props dsProps) {
return new MybatisAdapterFlex(dsWrap, dsProps);
}
+
}
From d804a8fd8b6acf822062d9ca9e45d1cd24c1f788 Mon Sep 17 00:00:00 2001
From: Suomm <1474983351@qq.com>
Date: Wed, 28 Jun 2023 10:06:52 +0800
Subject: [PATCH 02/17] =?UTF-8?q?style:=20=E6=B7=BB=E5=8A=A0=20MybatisAdap?=
=?UTF-8?q?terFlex=20=E6=B3=A8=E9=87=8A=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../solon/integration/MybatisAdapterFlex.java | 30 +++++++++++++++----
1 file changed, 24 insertions(+), 6 deletions(-)
diff --git a/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/integration/MybatisAdapterFlex.java b/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/integration/MybatisAdapterFlex.java
index 625c1da6..bd2e16cb 100644
--- a/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/integration/MybatisAdapterFlex.java
+++ b/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/integration/MybatisAdapterFlex.java
@@ -1,3 +1,19 @@
+/*
+ * 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.solon.integration;
import com.mybatisflex.core.FlexGlobalConfig;
@@ -17,15 +33,19 @@ import org.noear.solon.core.event.EventBus;
import javax.sql.DataSource;
/**
- * 适配器 for mybatis-flex
+ * MyBatis-Flex 适配器。
*
* @author noear
* @since 2.2
*/
public class MybatisAdapterFlex extends MybatisAdapterDefault {
+
FlexSqlSessionFactoryBuilder factoryBuilderPlus;
+
FlexGlobalConfig globalConfig;
+ RowMapperInvoker rowMapperInvoker;
+
protected MybatisAdapterFlex(BeanWrap dsWrap) {
super(dsWrap);
@@ -107,25 +127,23 @@ public class MybatisAdapterFlex extends MybatisAdapterDefault {
return factory;
}
- RowMapperInvoker rowMapperInvoker;
-
@Override
public void injectTo(VarHolder varH) {
super.injectTo(varH);
- //@Db("db1") FlexGlobalConfig globalConfig;
+ // @Db("db1") FlexGlobalConfig globalConfig
if (FlexGlobalConfig.class.isAssignableFrom(varH.getType())) {
varH.setValue(this.getGlobalConfig());
return;
}
- //@Db("db1") RowMapperInvoker rowMapper;
+ // @Db("db1") RowMapperInvoker rowMapper
if (RowMapperInvoker.class.equals(varH.getType())) {
if (rowMapperInvoker == null) {
rowMapperInvoker = new RowMapperInvoker(getFactory());
}
varH.setValue(rowMapperInvoker);
- return;
}
}
+
}
From c3cb222ccee0cedff2981ef7f67f1b97c7aa4854 Mon Sep 17 00:00:00 2001
From: Suomm <1474983351@qq.com>
Date: Wed, 28 Jun 2023 10:07:13 +0800
Subject: [PATCH 03/17] =?UTF-8?q?style:=20=E6=B7=BB=E5=8A=A0=20ServiceImpl?=
=?UTF-8?q?=20=E6=B3=A8=E9=87=8A=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../solon/service/impl/ServiceImpl.java | 34 +++++++++++--------
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/service/impl/ServiceImpl.java b/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/service/impl/ServiceImpl.java
index 0e91f0d6..80ef2adc 100644
--- a/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/service/impl/ServiceImpl.java
+++ b/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/service/impl/ServiceImpl.java
@@ -1,17 +1,17 @@
-/**
- * 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.
+/*
+ * 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.solon.service.impl;
@@ -19,6 +19,12 @@ import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.service.IService;
import org.noear.solon.annotation.Inject;
+/**
+ * 默认 {@link IService} 实现类。
+ *
+ * @param Mapper 类型
+ * @param Entity 类型
+ */
public class ServiceImpl, T> implements IService {
@Inject
From 30b078fac08fab6c15f4754a11cbd3a882f9612d Mon Sep 17 00:00:00 2001
From: Suomm <1474983351@qq.com>
Date: Wed, 28 Jun 2023 10:07:23 +0800
Subject: [PATCH 04/17] =?UTF-8?q?style:=20=E6=B7=BB=E5=8A=A0=20XPluginImpl?=
=?UTF-8?q?=20=E6=B3=A8=E9=87=8A=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../solon/integration/XPluginImpl.java | 23 ++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/integration/XPluginImpl.java b/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/integration/XPluginImpl.java
index 2d18826e..5e386fe3 100644
--- a/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/integration/XPluginImpl.java
+++ b/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/integration/XPluginImpl.java
@@ -1,3 +1,19 @@
+/*
+ * 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.solon.integration;
import org.apache.ibatis.solon.integration.MybatisAdapterManager;
@@ -5,15 +21,16 @@ import org.noear.solon.core.AopContext;
import org.noear.solon.core.Plugin;
/**
+ * 配置 MyBatis-Flex 插件。
+ *
* @author noear
* @since 2.2
*/
public class XPluginImpl implements Plugin {
+
@Override
- public void start(AopContext context) throws Throwable {
- //
+ public void start(AopContext context) {
// 此插件的 solon.plugin.priority 会大于 mybatis-solon-plugin 的值
- //
MybatisAdapterManager.setAdapterFactory(new MybatisAdapterFactoryFlex());
}
From 6185b433e1e30f1e511c8d42b99a2f09409063a8 Mon Sep 17 00:00:00 2001
From: Suomm <1474983351@qq.com>
Date: Wed, 28 Jun 2023 10:07:42 +0800
Subject: [PATCH 05/17] =?UTF-8?q?style:=20=E6=B7=BB=E5=8A=A0=20package-inf?=
=?UTF-8?q?o.java=20=E5=8C=85=E6=B3=A8=E9=87=8A=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../solon/integration/package-info.java | 20 +++++++++++++++++++
.../solon/service/impl/package-info.java | 20 +++++++++++++++++++
2 files changed, 40 insertions(+)
create mode 100644 mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/integration/package-info.java
create mode 100644 mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/service/impl/package-info.java
diff --git a/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/integration/package-info.java b/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/integration/package-info.java
new file mode 100644
index 00000000..2ca188b6
--- /dev/null
+++ b/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/integration/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * MyBatis-Flex Solon 支持。
+ */
+package com.mybatisflex.solon.integration;
\ No newline at end of file
diff --git a/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/service/impl/package-info.java b/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/service/impl/package-info.java
new file mode 100644
index 00000000..8f8d1d06
--- /dev/null
+++ b/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/service/impl/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * IService 实现。
+ */
+package com.mybatisflex.solon.service.impl;
\ No newline at end of file
From af718a6cff1c3ae2d5858c4550ef7d15f8838a74 Mon Sep 17 00:00:00 2001
From: Suomm <1474983351@qq.com>
Date: Wed, 28 Jun 2023 10:09:02 +0800
Subject: [PATCH 06/17] =?UTF-8?q?style:=20=E5=B1=9E=E6=80=A7=20dsCache=20?=
=?UTF-8?q?=E6=94=BE=E5=9C=A8=E7=B1=BB=E7=9A=84=E5=BC=80=E5=A7=8B=E4=BD=8D?=
=?UTF-8?q?=E7=BD=AE=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../spring/datasource/DataSourceInterceptor.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/datasource/DataSourceInterceptor.java b/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/datasource/DataSourceInterceptor.java
index ae4b7412..e0cc7894 100644
--- a/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/datasource/DataSourceInterceptor.java
+++ b/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/datasource/DataSourceInterceptor.java
@@ -36,6 +36,11 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class DataSourceInterceptor implements MethodInterceptor {
+ /**
+ * 缓存方法对应的数据源。
+ */
+ private final Map dsCache = new ConcurrentHashMap<>();
+
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
@@ -57,11 +62,6 @@ public class DataSourceInterceptor implements MethodInterceptor {
}
}
- /**
- * 缓存方法对应的数据源。
- */
- private final Map dsCache = new ConcurrentHashMap<>();
-
private String findDataSourceKey(Method method, Class> targetClass) {
Object cacheKey = new MethodClassKey(method, targetClass);
String dsKey = this.dsCache.get(cacheKey);
From 05f60c13ca6bf8b12af605760b5a63d76f37d268 Mon Sep 17 00:00:00 2001
From: Suomm <1474983351@qq.com>
Date: Wed, 28 Jun 2023 10:09:30 +0800
Subject: [PATCH 07/17] =?UTF-8?q?style:=20=E4=BC=98=E5=8C=96=20FlexSqlSess?=
=?UTF-8?q?ionFactoryBean=20=E6=B3=A8=E9=87=8A=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../spring/FlexSqlSessionFactoryBean.java | 36 ++++++++++---------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/FlexSqlSessionFactoryBean.java b/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/FlexSqlSessionFactoryBean.java
index 48e7697e..35bae23c 100644
--- a/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/FlexSqlSessionFactoryBean.java
+++ b/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/FlexSqlSessionFactoryBean.java
@@ -1,17 +1,17 @@
-/**
- * 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.
+/*
+ * 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.spring;
@@ -73,9 +73,11 @@ import static org.springframework.util.StringUtils.hasLength;
import static org.springframework.util.StringUtils.tokenizeToStringArray;
/**
- * spring 在定义 SqlSessionFactoryBean 的时候,需要替换为 FlexSqlSessionFactoryBean
- * 源于 {@link SqlSessionFactoryBean},主要是用于构建 {@link com.mybatisflex.core.mybatis.FlexConfiguration },而不是使用原生的 Configuration
- * 此代码主要是用于修改 {@link FlexSqlSessionFactoryBean#buildSqlSessionFactory()} 部分
+ *
Spring 在定义 SqlSessionFactoryBean 的时候,需要替换为 FlexSqlSessionFactoryBean。
+ *
+ *
源于 {@link SqlSessionFactoryBean},主要是用于构建 {@link com.mybatisflex.core.mybatis.FlexConfiguration },而不是使用原生的 {@link Configuration}。
+ *
+ *
此代码主要是用于修改 {@link FlexSqlSessionFactoryBean#buildSqlSessionFactory()} 部分。
*/
public class FlexSqlSessionFactoryBean extends SqlSessionFactoryBean
implements FactoryBean, InitializingBean, ApplicationListener {
From c870d1724cd3d719a0ae9e564df8d0311d2055bf Mon Sep 17 00:00:00 2001
From: Suomm <1474983351@qq.com>
Date: Wed, 28 Jun 2023 10:09:48 +0800
Subject: [PATCH 08/17] =?UTF-8?q?style:=20=E6=B7=BB=E5=8A=A0=20FlexTransac?=
=?UTF-8?q?tionManager=20=E6=B3=A8=E9=87=8A=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../spring/FlexTransactionManager.java | 31 ++++++++++---------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/FlexTransactionManager.java b/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/FlexTransactionManager.java
index 96e1b7fa..944da5a6 100644
--- a/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/FlexTransactionManager.java
+++ b/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/FlexTransactionManager.java
@@ -1,17 +1,17 @@
-/**
- * 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.
+/*
+ * 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.spring;
@@ -23,6 +23,9 @@ import org.springframework.transaction.TransactionException;
import org.springframework.transaction.support.AbstractPlatformTransactionManager;
import org.springframework.transaction.support.DefaultTransactionStatus;
+/**
+ * MyBatis-Flex 事务支持。
+ */
public class FlexTransactionManager extends AbstractPlatformTransactionManager {
@Override
From 19f2ab5fd837fccb0ea25168622f70550a59db00 Mon Sep 17 00:00:00 2001
From: Suomm <1474983351@qq.com>
Date: Wed, 28 Jun 2023 10:10:04 +0800
Subject: [PATCH 09/17] =?UTF-8?q?style:=20=E6=B7=BB=E5=8A=A0=20package-inf?=
=?UTF-8?q?o.java=20=E5=8C=85=E6=B3=A8=E9=87=8A=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../spring/datasource/package-info.java | 20 +++++++++++++++++++
.../com/mybatisflex/spring/package-info.java | 20 +++++++++++++++++++
.../spring/service/impl/package-info.java | 20 +++++++++++++++++++
3 files changed, 60 insertions(+)
create mode 100644 mybatis-flex-spring/src/main/java/com/mybatisflex/spring/datasource/package-info.java
create mode 100644 mybatis-flex-spring/src/main/java/com/mybatisflex/spring/package-info.java
create mode 100644 mybatis-flex-spring/src/main/java/com/mybatisflex/spring/service/impl/package-info.java
diff --git a/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/datasource/package-info.java b/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/datasource/package-info.java
new file mode 100644
index 00000000..b3bd6ffe
--- /dev/null
+++ b/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/datasource/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.spring.datasource;
\ No newline at end of file
diff --git a/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/package-info.java b/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/package-info.java
new file mode 100644
index 00000000..97288aea
--- /dev/null
+++ b/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * MyBatis-Flex Spring 支持。
+ */
+package com.mybatisflex.spring;
\ No newline at end of file
diff --git a/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/service/impl/package-info.java b/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/service/impl/package-info.java
new file mode 100644
index 00000000..555bce31
--- /dev/null
+++ b/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/service/impl/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * IService 实现。
+ */
+package com.mybatisflex.spring.service.impl;
\ No newline at end of file
From 79a0ecdacbc73252e4e69e81e9b4a6bc925f8c43 Mon Sep 17 00:00:00 2001
From: Suomm <1474983351@qq.com>
Date: Wed, 28 Jun 2023 10:10:22 +0800
Subject: [PATCH 10/17] =?UTF-8?q?style:=20=E6=B7=BB=E5=8A=A0=20Conditional?=
=?UTF-8?q?OnMybatisFlexDatasource=20=E6=B3=A8=E9=87=8A=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../spring/boot/ConditionalOnMybatisFlexDatasource.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/ConditionalOnMybatisFlexDatasource.java b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/ConditionalOnMybatisFlexDatasource.java
index 604fcb4a..125cdf29 100644
--- a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/ConditionalOnMybatisFlexDatasource.java
+++ b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/ConditionalOnMybatisFlexDatasource.java
@@ -30,7 +30,11 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.Iterator;
-
+/**
+ *
判断是否有 MyBatis-Flex 的多数据源配置。
+ *
+ *
如果配置文件中有 MyBatis-Flex 的多数据源配置,就加载 MyBatis-Flex 多数据源自动配置类。
+ */
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Conditional(ConditionalOnMybatisFlexDatasource.OnMybatisFlexDataSourceCondition.class)
From a9d19464fcfcd05703bb070a831cfc67a05f7bd1 Mon Sep 17 00:00:00 2001
From: Suomm <1474983351@qq.com>
Date: Wed, 28 Jun 2023 10:10:41 +0800
Subject: [PATCH 11/17] =?UTF-8?q?style:=20=E6=B7=BB=E5=8A=A0=20Configurati?=
=?UTF-8?q?onCustomizer=20=E6=B3=A8=E9=87=8A=EF=BC=8C=E6=A0=BC=E5=BC=8F?=
=?UTF-8?q?=E5=8C=96=E4=BB=A3=E7=A0=81=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../spring/boot/ConfigurationCustomizer.java | 37 +++++++++++--------
1 file changed, 21 insertions(+), 16 deletions(-)
diff --git a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/ConfigurationCustomizer.java b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/ConfigurationCustomizer.java
index c028c1d0..4a78c674 100644
--- a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/ConfigurationCustomizer.java
+++ b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/ConfigurationCustomizer.java
@@ -1,28 +1,33 @@
-/**
- * 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.
+/*
+ * 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.spring.boot;
import com.mybatisflex.core.mybatis.FlexConfiguration;
/**
- * 为 FlexConfiguration 做自定义的配置支持 {@link FlexConfiguration}
+ * 为 {@link FlexConfiguration} 做自定义的配置支持。
*/
@FunctionalInterface
public interface ConfigurationCustomizer {
- void customize(FlexConfiguration configuration);
+ /**
+ * 自定义配置 {@link FlexConfiguration}。
+ *
+ * @param configuration MyBatis Flex Configuration
+ */
+ void customize(FlexConfiguration configuration);
}
From 22763670ca177af806c4507b5e3fe8a934af6ffd Mon Sep 17 00:00:00 2001
From: Suomm <1474983351@qq.com>
Date: Wed, 28 Jun 2023 10:10:52 +0800
Subject: [PATCH 12/17] =?UTF-8?q?style:=20=E6=B7=BB=E5=8A=A0=20SqlSessionF?=
=?UTF-8?q?actoryBeanCustomizer=20=E6=B3=A8=E9=87=8A=EF=BC=8C=E6=A0=BC?=
=?UTF-8?q?=E5=BC=8F=E5=8C=96=E4=BB=A3=E7=A0=81=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../boot/SqlSessionFactoryBeanCustomizer.java | 38 +++++++++++--------
1 file changed, 22 insertions(+), 16 deletions(-)
diff --git a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/SqlSessionFactoryBeanCustomizer.java b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/SqlSessionFactoryBeanCustomizer.java
index da6202d7..3aacfb91 100644
--- a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/SqlSessionFactoryBeanCustomizer.java
+++ b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/SqlSessionFactoryBeanCustomizer.java
@@ -1,29 +1,35 @@
-/**
- * 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.
+/*
+ * 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.spring.boot;
import org.mybatis.spring.SqlSessionFactoryBean;
/**
- * 为 FlexSqlSessionFactoryBean 做自定义的配置支持
+ * 为 FlexSqlSessionFactoryBean 做自定义的配置支持。
+ *
* @see com.mybatisflex.spring.FlexSqlSessionFactoryBean
*/
@FunctionalInterface
public interface SqlSessionFactoryBeanCustomizer {
- void customize(SqlSessionFactoryBean factoryBean);
+ /**
+ * 自定义 {@link SqlSessionFactoryBean}。
+ *
+ * @param factoryBean FlexSqlSessionFactoryBean
+ */
+ void customize(SqlSessionFactoryBean factoryBean);
}
From 4ec9980999438ab714b110cf3254e1e54ecbed51 Mon Sep 17 00:00:00 2001
From: Suomm <1474983351@qq.com>
Date: Wed, 28 Jun 2023 10:12:08 +0800
Subject: [PATCH 13/17] =?UTF-8?q?style:=20=E6=B7=BB=E5=8A=A0=20SpringBootV?=
=?UTF-8?q?FS=20=E6=B3=A8=E9=87=8A=EF=BC=8C=E6=A0=BC=E5=BC=8F=E5=8C=96?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../spring/boot/SpringBootVFS.java | 125 +++++++++---------
1 file changed, 62 insertions(+), 63 deletions(-)
diff --git a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/SpringBootVFS.java b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/SpringBootVFS.java
index 067954bf..a6d81953 100644
--- a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/SpringBootVFS.java
+++ b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/SpringBootVFS.java
@@ -1,17 +1,17 @@
-/**
- * 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.
+/*
+ * 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.spring.boot;
@@ -31,59 +31,58 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
- * Mybatis 的 VFS 支持
+ * MyBatis 的 VFS 支持。
*/
public class SpringBootVFS extends VFS {
- private static Charset urlDecodingCharset;
- private final ResourcePatternResolver resourceResolver;
+ private static Charset urlDecodingCharset;
- static {
- setUrlDecodingCharset(Charset.defaultCharset());
- }
-
- public SpringBootVFS() {
- this.resourceResolver = new PathMatchingResourcePatternResolver(getClass().getClassLoader());
- }
-
- @Override
- public boolean isValid() {
- return true;
- }
-
- @Override
- protected List list(URL url, String path) throws IOException {
- String urlString = URLDecoder.decode(url.toString(), urlDecodingCharset.name());
- String baseUrlString = urlString.endsWith("/") ? urlString : urlString.concat("/");
- Resource[] resources = resourceResolver.getResources(baseUrlString + "**/*.class");
- return Stream.of(resources).map(resource -> preserveSubpackageName(baseUrlString, resource, path))
- .collect(Collectors.toList());
- }
-
- /**
- * Set the charset for decoding an encoded URL string.
- *
- * Default is system default charset.
- *
- *
- * @param charset
- * the charset for decoding an encoded URL string
- *
- * @since 2.3.0
- */
- public static void setUrlDecodingCharset(Charset charset) {
- urlDecodingCharset = charset;
- }
-
- private static String preserveSubpackageName(final String baseUrlString, final Resource resource,
- final String rootPath) {
- try {
- return rootPath + (rootPath.endsWith("/") ? "" : "/") + Normalizer
- .normalize(URLDecoder.decode(resource.getURL().toString(), urlDecodingCharset.name()), Normalizer.Form.NFC)
- .substring(baseUrlString.length());
- } catch (IOException e) {
- throw new UncheckedIOException(e);
+ static {
+ setUrlDecodingCharset(Charset.defaultCharset());
+ }
+
+ private final ResourcePatternResolver resourceResolver;
+
+ public SpringBootVFS() {
+ this.resourceResolver = new PathMatchingResourcePatternResolver(getClass().getClassLoader());
+ }
+
+ /**
+ * Set the charset for decoding an encoded URL string.
+ *
+ * Default is system default charset.
+ *
+ *
+ * @param charset the charset for decoding an encoded URL string
+ * @since 2.3.0
+ */
+ public static void setUrlDecodingCharset(Charset charset) {
+ urlDecodingCharset = charset;
+ }
+
+ private static String preserveSubpackageName(final String baseUrlString, final Resource resource,
+ final String rootPath) {
+ try {
+ return rootPath + (rootPath.endsWith("/") ? "" : "/") + Normalizer
+ .normalize(URLDecoder.decode(resource.getURL().toString(), urlDecodingCharset.name()), Normalizer.Form.NFC)
+ .substring(baseUrlString.length());
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
+ @Override
+ public boolean isValid() {
+ return true;
+ }
+
+ @Override
+ protected List list(URL url, String path) throws IOException {
+ String urlString = URLDecoder.decode(url.toString(), urlDecodingCharset.name());
+ String baseUrlString = urlString.endsWith("/") ? urlString : urlString.concat("/");
+ Resource[] resources = resourceResolver.getResources(baseUrlString + "**/*.class");
+ return Stream.of(resources).map(resource -> preserveSubpackageName(baseUrlString, resource, path))
+ .collect(Collectors.toList());
}
- }
}
From 94314e50db5ef9151be5169c11a468b667620f00 Mon Sep 17 00:00:00 2001
From: Suomm <1474983351@qq.com>
Date: Wed, 28 Jun 2023 10:12:29 +0800
Subject: [PATCH 14/17] =?UTF-8?q?style:=20=E6=B7=BB=E5=8A=A0=20FlexTransac?=
=?UTF-8?q?tionAutoConfiguration=20=E6=B3=A8=E9=87=8A=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../FlexTransactionAutoConfiguration.java | 41 ++++++++++++-------
1 file changed, 26 insertions(+), 15 deletions(-)
diff --git a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/FlexTransactionAutoConfiguration.java b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/FlexTransactionAutoConfiguration.java
index 22a983cb..fe73bf39 100644
--- a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/FlexTransactionAutoConfiguration.java
+++ b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/FlexTransactionAutoConfiguration.java
@@ -1,17 +1,17 @@
-/**
- * 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.
+/*
+ * 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.spring.boot;
@@ -26,16 +26,27 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.TransactionManagementConfigurer;
+/**
+ * MyBatis-Flex 事务自动配置。
+ */
@ConditionalOnClass(Db.class)
@Configuration(proxyBeanMethods = false)
@AutoConfigureAfter({MybatisFlexAutoConfiguration.class})
@AutoConfigureBefore({TransactionAutoConfiguration.class})
public class FlexTransactionAutoConfiguration implements TransactionManagementConfigurer {
+ /**
+ * 这里使用 final 修饰属性是因为:
+ *
+ * 1、调用 {@link #annotationDrivenTransactionManager} 方法会返回 TransactionManager 对象
+ * 2、{@code @Bean} 注入又会返回 TransactionManager 对象
+ *
+ * 需要保证两个对象的一致性。
+ */
private final FlexTransactionManager flexTransactionManager = new FlexTransactionManager();
- @Override
@Bean
+ @Override
public PlatformTransactionManager annotationDrivenTransactionManager() {
return flexTransactionManager;
}
From 64227136c4e87f28bb832c80a4c57aef1113a7fe Mon Sep 17 00:00:00 2001
From: Suomm <1474983351@qq.com>
Date: Wed, 28 Jun 2023 10:12:46 +0800
Subject: [PATCH 15/17] =?UTF-8?q?style:=20=E6=B7=BB=E5=8A=A0=20MultiDataSo?=
=?UTF-8?q?urceAutoConfiguration=20=E6=B3=A8=E9=87=8A=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../spring/boot/MultiDataSourceAutoConfiguration.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MultiDataSourceAutoConfiguration.java b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MultiDataSourceAutoConfiguration.java
index 51ca2625..1ff89fba 100644
--- a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MultiDataSourceAutoConfiguration.java
+++ b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MultiDataSourceAutoConfiguration.java
@@ -34,7 +34,7 @@ import java.util.Map;
/**
- * 多数据源的配置支持
+ * MyBatis-Flex 多数据源的配置支持。
*/
@ConditionalOnMybatisFlexDatasource()
@Configuration(proxyBeanMethods = false)
@@ -50,7 +50,6 @@ public class MultiDataSourceAutoConfiguration {
dataSourceProperties = properties.getDatasource();
}
-
@Bean
@ConditionalOnMissingBean
public DataSource dataSource() {
@@ -71,6 +70,9 @@ public class MultiDataSourceAutoConfiguration {
return flexDataSource;
}
+ /**
+ * {@link com.mybatisflex.annotation.UseDataSource} 注解切换数据源切面。
+ */
@Bean
@ConditionalOnMissingBean
public DataSourceAdvice dataSourceAdvice() {
From 68e8816886765e47d41bcec85a758486ab414b1a Mon Sep 17 00:00:00 2001
From: Suomm <1474983351@qq.com>
Date: Wed, 28 Jun 2023 10:14:10 +0800
Subject: [PATCH 16/17] =?UTF-8?q?style:=20=E6=B7=BB=E5=8A=A0=20MybatisLang?=
=?UTF-8?q?uageDriverAutoConfiguration=20=E6=B3=A8=E9=87=8A=EF=BC=8C?=
=?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BB=A3=E7=A0=81=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...ybatisLanguageDriverAutoConfiguration.java | 214 +++++++++---------
1 file changed, 107 insertions(+), 107 deletions(-)
diff --git a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MybatisLanguageDriverAutoConfiguration.java b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MybatisLanguageDriverAutoConfiguration.java
index 72f17369..4453c82e 100644
--- a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MybatisLanguageDriverAutoConfiguration.java
+++ b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/MybatisLanguageDriverAutoConfiguration.java
@@ -1,17 +1,17 @@
-/**
- * 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.
+/*
+ * 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.spring.boot;
@@ -30,117 +30,117 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
- * 脚本语言驱动的自动配置,平常一般项目用不到,只为了同步 mybatis 自带的 MybatisLanguageDriverAutoConfiguration
+ * 脚本语言驱动的自动配置,平常一般项目用不到,只为了同步 MyBatis 自带的 MybatisLanguageDriverAutoConfiguration。
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(LanguageDriver.class)
public class MybatisLanguageDriverAutoConfiguration {
- private static final String CONFIGURATION_PROPERTY_PREFIX = "mybatis-flex.scripting-language-driver";
+ private static final String CONFIGURATION_PROPERTY_PREFIX = "mybatis-flex.scripting-language-driver";
- /**
- * Configuration class for mybatis-freemarker 1.1.x or under.
- */
- @Configuration(proxyBeanMethods = false)
- @ConditionalOnClass(FreeMarkerLanguageDriver.class)
- @ConditionalOnMissingClass("org.mybatis.scripting.freemarker.FreeMarkerLanguageDriverConfig")
- public static class LegacyFreeMarkerConfiguration {
- @Bean
- @ConditionalOnMissingBean
- FreeMarkerLanguageDriver freeMarkerLanguageDriver() {
- return new FreeMarkerLanguageDriver();
- }
- }
-
- /**
- * Configuration class for mybatis-freemarker 1.2.x or above.
- */
- @Configuration(proxyBeanMethods = false)
- @ConditionalOnClass({ FreeMarkerLanguageDriver.class, FreeMarkerLanguageDriverConfig.class })
- public static class FreeMarkerConfiguration {
- @Bean
- @ConditionalOnMissingBean
- FreeMarkerLanguageDriver freeMarkerLanguageDriver(FreeMarkerLanguageDriverConfig config) {
- return new FreeMarkerLanguageDriver(config);
+ /**
+ * Configuration class for mybatis-freemarker 1.1.x or under.
+ */
+ @Configuration(proxyBeanMethods = false)
+ @ConditionalOnClass(FreeMarkerLanguageDriver.class)
+ @ConditionalOnMissingClass("org.mybatis.scripting.freemarker.FreeMarkerLanguageDriverConfig")
+ public static class LegacyFreeMarkerConfiguration {
+ @Bean
+ @ConditionalOnMissingBean
+ FreeMarkerLanguageDriver freeMarkerLanguageDriver() {
+ return new FreeMarkerLanguageDriver();
+ }
}
- @Bean
- @ConditionalOnMissingBean
- @ConfigurationProperties(CONFIGURATION_PROPERTY_PREFIX + ".freemarker")
- public FreeMarkerLanguageDriverConfig freeMarkerLanguageDriverConfig() {
- return FreeMarkerLanguageDriverConfig.newInstance();
- }
- }
+ /**
+ * Configuration class for mybatis-freemarker 1.2.x or above.
+ */
+ @Configuration(proxyBeanMethods = false)
+ @ConditionalOnClass({FreeMarkerLanguageDriver.class, FreeMarkerLanguageDriverConfig.class})
+ public static class FreeMarkerConfiguration {
+ @Bean
+ @ConditionalOnMissingBean
+ FreeMarkerLanguageDriver freeMarkerLanguageDriver(FreeMarkerLanguageDriverConfig config) {
+ return new FreeMarkerLanguageDriver(config);
+ }
- /**
- * Configuration class for mybatis-velocity 2.0 or under.
- */
- @Configuration(proxyBeanMethods = false)
- @ConditionalOnClass(org.mybatis.scripting.velocity.Driver.class)
- @ConditionalOnMissingClass("org.mybatis.scripting.velocity.VelocityLanguageDriverConfig")
- @SuppressWarnings("deprecation")
- public static class LegacyVelocityConfiguration {
- @Bean
- @ConditionalOnMissingBean
- org.mybatis.scripting.velocity.Driver velocityLanguageDriver() {
- return new org.mybatis.scripting.velocity.Driver();
- }
- }
-
- /**
- * Configuration class for mybatis-velocity 2.1.x or above.
- */
- @Configuration(proxyBeanMethods = false)
- @ConditionalOnClass({ VelocityLanguageDriver.class, VelocityLanguageDriverConfig.class })
- public static class VelocityConfiguration {
- @Bean
- @ConditionalOnMissingBean
- VelocityLanguageDriver velocityLanguageDriver(VelocityLanguageDriverConfig config) {
- return new VelocityLanguageDriver(config);
+ @Bean
+ @ConditionalOnMissingBean
+ @ConfigurationProperties(CONFIGURATION_PROPERTY_PREFIX + ".freemarker")
+ public FreeMarkerLanguageDriverConfig freeMarkerLanguageDriverConfig() {
+ return FreeMarkerLanguageDriverConfig.newInstance();
+ }
}
- @Bean
- @ConditionalOnMissingBean
- @ConfigurationProperties(CONFIGURATION_PROPERTY_PREFIX + ".velocity")
- public VelocityLanguageDriverConfig velocityLanguageDriverConfig() {
- return VelocityLanguageDriverConfig.newInstance();
- }
- }
-
- @Configuration(proxyBeanMethods = false)
- @ConditionalOnClass(ThymeleafLanguageDriver.class)
- public static class ThymeleafConfiguration {
- @Bean
- @ConditionalOnMissingBean
- ThymeleafLanguageDriver thymeleafLanguageDriver(ThymeleafLanguageDriverConfig config) {
- return new ThymeleafLanguageDriver(config);
+ /**
+ * Configuration class for mybatis-velocity 2.0 or under.
+ */
+ @Configuration(proxyBeanMethods = false)
+ @ConditionalOnClass(org.mybatis.scripting.velocity.Driver.class)
+ @ConditionalOnMissingClass("org.mybatis.scripting.velocity.VelocityLanguageDriverConfig")
+ @SuppressWarnings("deprecation")
+ public static class LegacyVelocityConfiguration {
+ @Bean
+ @ConditionalOnMissingBean
+ org.mybatis.scripting.velocity.Driver velocityLanguageDriver() {
+ return new org.mybatis.scripting.velocity.Driver();
+ }
}
- @Bean
- @ConditionalOnMissingBean
- @ConfigurationProperties(CONFIGURATION_PROPERTY_PREFIX + ".thymeleaf")
- public ThymeleafLanguageDriverConfig thymeleafLanguageDriverConfig() {
- return ThymeleafLanguageDriverConfig.newInstance();
+ /**
+ * Configuration class for mybatis-velocity 2.1.x or above.
+ */
+ @Configuration(proxyBeanMethods = false)
+ @ConditionalOnClass({VelocityLanguageDriver.class, VelocityLanguageDriverConfig.class})
+ public static class VelocityConfiguration {
+ @Bean
+ @ConditionalOnMissingBean
+ VelocityLanguageDriver velocityLanguageDriver(VelocityLanguageDriverConfig config) {
+ return new VelocityLanguageDriver(config);
+ }
+
+ @Bean
+ @ConditionalOnMissingBean
+ @ConfigurationProperties(CONFIGURATION_PROPERTY_PREFIX + ".velocity")
+ public VelocityLanguageDriverConfig velocityLanguageDriverConfig() {
+ return VelocityLanguageDriverConfig.newInstance();
+ }
}
- // This class provides to avoid the https://github.com/spring-projects/spring-boot/issues/21626 as workaround.
- @SuppressWarnings("unused")
- private static class MetadataThymeleafLanguageDriverConfig extends ThymeleafLanguageDriverConfig {
+ @Configuration(proxyBeanMethods = false)
+ @ConditionalOnClass(ThymeleafLanguageDriver.class)
+ public static class ThymeleafConfiguration {
+ @Bean
+ @ConditionalOnMissingBean
+ ThymeleafLanguageDriver thymeleafLanguageDriver(ThymeleafLanguageDriverConfig config) {
+ return new ThymeleafLanguageDriver(config);
+ }
- @ConfigurationProperties(CONFIGURATION_PROPERTY_PREFIX + ".thymeleaf.dialect")
- @Override
- public DialectConfig getDialect() {
- return super.getDialect();
- }
+ @Bean
+ @ConditionalOnMissingBean
+ @ConfigurationProperties(CONFIGURATION_PROPERTY_PREFIX + ".thymeleaf")
+ public ThymeleafLanguageDriverConfig thymeleafLanguageDriverConfig() {
+ return ThymeleafLanguageDriverConfig.newInstance();
+ }
- @ConfigurationProperties(CONFIGURATION_PROPERTY_PREFIX + ".thymeleaf.template-file")
- @Override
- public TemplateFileConfig getTemplateFile() {
- return super.getTemplateFile();
- }
+ // This class provides to avoid the https://github.com/spring-projects/spring-boot/issues/21626 as workaround.
+ @SuppressWarnings("unused")
+ private static class MetadataThymeleafLanguageDriverConfig extends ThymeleafLanguageDriverConfig {
+
+ @ConfigurationProperties(CONFIGURATION_PROPERTY_PREFIX + ".thymeleaf.dialect")
+ @Override
+ public DialectConfig getDialect() {
+ return super.getDialect();
+ }
+
+ @ConfigurationProperties(CONFIGURATION_PROPERTY_PREFIX + ".thymeleaf.template-file")
+ @Override
+ public TemplateFileConfig getTemplateFile() {
+ return super.getTemplateFile();
+ }
+
+ }
}
- }
-
}
From e7d55d6b4725838fc7d785f868edb9942919d2c3 Mon Sep 17 00:00:00 2001
From: Suomm <1474983351@qq.com>
Date: Wed, 28 Jun 2023 10:14:35 +0800
Subject: [PATCH 17/17] =?UTF-8?q?style:=20=E6=B7=BB=E5=8A=A0=20package-inf?=
=?UTF-8?q?o.java=20=E5=8C=85=E6=B3=A8=E9=87=8A=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../mybatisflex/spring/boot/package-info.java | 34 +++++++++++--------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/package-info.java b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/package-info.java
index b90c4ad2..b80209dc 100644
--- a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/package-info.java
+++ b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/package-info.java
@@ -1,16 +1,20 @@
-/**
- * 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.
+/*
+ * 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.spring.boot;
+
+/**
+ * MyBatis-Flex Spring Boot 支持。
+ */
+package com.mybatisflex.spring.boot;
\ No newline at end of file