Skip to content

Commit c6611c9

Browse files
author
Weasley
committed
update
1 parent f1c3d15 commit c6611c9

File tree

7 files changed

+19
-20
lines changed

7 files changed

+19
-20
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ Domain Driven Table [![Maven Central](https://img.shields.io/maven-central/v/io.
251251
<dependency>
252252
<groupId>io.github.weasley-j</groupId>
253253
<artifactId>mydtt-plus-spring-boot-starter</artifactId>
254-
<version>1.3.3</version>
254+
<version>1.3.4</version>
255255
</dependency>
256256
<!-- javadoc-scribe start -->
257257
<dependency>
@@ -293,7 +293,7 @@ mvn clean install -pl :mydtt-plus-spring-boot-starter -am
293293
<dependency>
294294
<groupId>io.github.weasley-j</groupId>
295295
<artifactId>mydtt-plus-spring-boot-starter</artifactId>
296-
<version>1.3.3</version>
296+
<version>1.3.4</version>
297297
</dependency>
298298
<!-- javadoc-scribe start -->
299299
<dependency>

embedded-db/h2.mv.db

4 KB
Binary file not shown.

mydtt-plus-spring-boot-starter-tests/mydtt-plus-spring-boot-2-x/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<dependency>
2626
<groupId>io.github.weasley-j</groupId>
2727
<artifactId>mydtt-plus-spring-boot-starter</artifactId>
28-
<version>1.3.3</version>
28+
<version>1.3.4</version>
2929
</dependency>
3030
<!-- javadoc-scribe start -->
3131
<dependency>

mydtt-plus-spring-boot-starter-tests/mydtt-plus-spring-boot-3-x/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<dependency>
4141
<groupId>io.github.weasley-j</groupId>
4242
<artifactId>mydtt-plus-spring-boot-starter</artifactId>
43-
<version>1.3.3</version>
43+
<version>1.3.4</version>
4444
</dependency>
4545
<!-- javadoc-scribe start -->
4646
<dependency>

mydtt-plus-spring-boot-starter/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<groupId>io.github.weasley-j</groupId>
1313
<artifactId>mydtt-plus-spring-boot-starter</artifactId>
14-
<version>1.3.3</version>
14+
<version>1.3.4</version>
1515
<name>mydtt-plus-spring-boot-starter</name>
1616
<description>
1717
MyDtt-Plus is a starter of SpringBoot,I named it DTT, It's an object-oriented Java framework,

mydtt-plus-spring-boot-starter/src/main/java/cn/alphahub/dtt/plus/config/DttMybatisAutoConfiguration.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
@AutoConfigureAfter(name = {"mybatisAutoConfiguration", "mybatisPlusAutoConfiguration"})
5555
public class DttMybatisAutoConfiguration implements InitializingBean {
5656
private static final String[] MYBATIS_PROP_PREFIX = {"mybatis-plus.type-aliases-package", "mybatis.type-aliases-package"};
57-
private static final String[] shardingSphereBeans = {"shardingSphereAutoConfiguration", "org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration"};
57+
private static final String[] SHARDING_SPHERE_BEANS = {"shardingSphereAutoConfiguration", "org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration"};
5858
private final Logger logger = LoggerFactory.getLogger(this.getClass());
5959
/**
6060
* The type aliases map of mybatis
@@ -76,6 +76,7 @@ public class DttMybatisAutoConfiguration implements InitializingBean {
7676
*/
7777
private final DefaultDttMybatisInterceptor defaultDttMybatisInterceptor;
7878
private final DttMybatisOrmSupportProperties dttMybatisOrmSupportProperties;
79+
private Boolean shardingSphereEnable = false;
7980

8081
public DttMybatisAutoConfiguration(JdbcTemplate jdbcTemplate,
8182
DttProperties dttProperties,
@@ -97,22 +98,18 @@ public DttMybatisAutoConfiguration(JdbcTemplate jdbcTemplate,
9798

9899
@Override
99100
public void afterPropertiesSet() {
100-
if (dttMybatisOrmSupportProperties.getIsEnable().equals(false) || isShardingSphereEnable()) return;
101-
101+
if (dttMybatisOrmSupportProperties.getIsEnable().equals(false)) return;
102+
this.shardingSphereEnable = isShardingSphereEnable();
102103
sqlSessionFactories.forEach(sqlSessionFactory -> {
103104
Configuration configuration = sqlSessionFactory.getConfiguration();
104105
if (ObjectUtils.isNotEmpty(configuration) && !configuration.getInterceptors().contains(defaultDttMybatisInterceptor)) {
105106
configuration.addInterceptor(defaultDttMybatisInterceptor);
106107
}
107108
});
108-
109-
if (logger.isInfoEnabled()) {
110-
logger.info("Loading..., " +
111-
"DTT is judging the existence of all tables for caching, it's will take a few seconds," +
112-
"if you want to disable dtt-mybatis-orm-support," +
113-
"please set 'alphahub.dtt.mybatis-orm-support.is-enable' to 'false'.");
109+
if (logger.isInfoEnabled() && shardingSphereEnable.equals(false)) {
110+
logger.info("DTT is judging the existence of all tables for caching, it's will take a few seconds," +
111+
"if you want to disable dtt-mybatis-orm-support, please set 'alphahub.dtt.mybatis-orm-support.is-enable' to 'false'.");
114112
}
115-
116113
for (String mybatisPropPrefix : MYBATIS_PROP_PREFIX) {
117114
String property = SpringUtil.getProperty(mybatisPropPrefix);
118115
if (StringUtils.isBlank(property)) continue;
@@ -124,7 +121,9 @@ public void afterPropertiesSet() {
124121
actWrapper.setDomainName(com.baomidou.mybatisplus.core.toolkit.StringUtils.firstToLowerCase(value.getSimpleName()));
125122
actWrapper.setDomainClass(value);
126123
String tableName = com.baomidou.mybatisplus.core.toolkit.StringUtils.camelToUnderline(value.getSimpleName());
127-
actWrapper.setTableNotExists(isTableNotExists(tableName));
124+
if (shardingSphereEnable.equals(false)) {
125+
actWrapper.setTableNotExists(isTableNotExists(tableName));
126+
}
128127
return actWrapper;
129128
})));
130129
this.typeAliasesMap.putAll(classConcurrentMap);
@@ -138,7 +137,7 @@ public void afterPropertiesSet() {
138137
* @return if enable return true
139138
* @see <a href="https://shardingsphere.apache.org/document/5.1.2/cn/user-manual/shardingsphere-jdbc/spring-boot-starter/">ShardingSphere Auto-Configuration</a>
140139
*/
141-
public boolean isShardingSphereEnable() {
140+
protected boolean isShardingSphereEnable() {
142141
boolean isShardingSphereEnable = false;
143142
try {
144143
Class<?> shardingSphereDriver = Class.forName("org.apache.shardingsphere.driver.ShardingSphereDriver");
@@ -148,7 +147,7 @@ public boolean isShardingSphereEnable() {
148147
} catch (Exception e) {
149148
// No dump
150149
}
151-
for (String shardingSphereBean : shardingSphereBeans) {
150+
for (String shardingSphereBean : SHARDING_SPHERE_BEANS) {
152151
try {
153152
if (ObjectUtils.isNotEmpty(applicationContext.getBean(shardingSphereBean)))
154153
isShardingSphereEnable = true;

mydtt-plus-spring-boot-starter/src/main/java/cn/alphahub/dtt/plus/framework/interceptor/DefaultDttMybatisInterceptor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ private void createTableIfNotExists(List<String> tableNames) {
101101
Map<String, DttMbActWrapper> typeAliasesMap = dttMybatisAutoConfiguration.getTypeAliasesMap();
102102
if (CollectionUtils.isEmpty(typeAliasesMap)) return;
103103

104-
boolean isShardingSphereEnable = dttMybatisAutoConfiguration.isShardingSphereEnable();
104+
boolean shardingSphereEnable = dttMybatisAutoConfiguration.getShardingSphereEnable();
105105

106-
if (isShardingSphereEnable) {
106+
if (shardingSphereEnable) {
107107
// TODO: compatibility with sharding-sphere, May be compatible later
108108
return;
109109
}

0 commit comments

Comments
 (0)