1. 初始化
This commit is contained in:
parent
a5945b24e1
commit
72c4a0374c
|
|
@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.baomidou.mybatisplus.core.handlers.PostInitTableInfoHandler;
|
||||
import com.baomidou.mybatisplus.core.incrementer.IKeyGenerator;
|
||||
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
||||
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
|
||||
|
|
@ -77,6 +78,11 @@ public class GlobalConfig implements Serializable {
|
|||
* 元对象字段填充控制器
|
||||
*/
|
||||
private MetaObjectHandler metaObjectHandler;
|
||||
/**
|
||||
* 参与 TableInfo 的初始化
|
||||
*/
|
||||
private PostInitTableInfoHandler postInitTableInfoHandler = new PostInitTableInfoHandler() {
|
||||
};
|
||||
/**
|
||||
* 主键生成器
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -58,8 +58,6 @@ import java.util.stream.Collectors;
|
|||
*
|
||||
* @author hubin
|
||||
* @since 3.4.0
|
||||
*
|
||||
* 修改无法使用原生sql 的 warn 打印
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
|
@ -333,13 +331,22 @@ public class PaginationInnerInterceptor implements InnerInterceptor {
|
|||
}
|
||||
// 不区分大小写
|
||||
str = str.toLowerCase();
|
||||
String onExpressionS = join.getOnExpression().toString();
|
||||
/* 如果 join 里包含 ?(代表有入参) 或者 where 条件里包含使用 join 的表的字段作条件,就不移除 join */
|
||||
if (onExpressionS.contains(StringPool.QUESTION_MARK) || whereS.contains(str)) {
|
||||
|
||||
if (whereS.contains(str)) {
|
||||
/* 如果 where 条件里包含使用 join 的表的字段作条件,就不移除 join */
|
||||
canRemoveJoin = false;
|
||||
break;
|
||||
}
|
||||
|
||||
for (Expression expression : join.getOnExpressions()) {
|
||||
if (expression.toString().contains(StringPool.QUESTION_MARK)) {
|
||||
/* 如果 join 里包含 ?(代表有入参) 就不移除 join */
|
||||
canRemoveJoin = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (canRemoveJoin) {
|
||||
plainSelect.setJoins(null);
|
||||
}
|
||||
|
|
@ -350,7 +357,7 @@ public class PaginationInnerInterceptor implements InnerInterceptor {
|
|||
return select.toString();
|
||||
} catch (JSQLParserException e) {
|
||||
// 无法优化使用原 SQL
|
||||
logger.warn("无法优化使用原生sql");
|
||||
logger.warn("optimize this sql to a count sql has exception, sql:\"" + sql + "\", exception:\n" + e.getCause());
|
||||
} catch (Exception e) {
|
||||
logger.warn("optimize this sql to a count sql has error, sql:\"" + sql + "\", exception:\n" + e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.chushang.redis.config;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.chushang.common.core.exception.utils.AssertUtil;
|
||||
import com.chushang.common.core.util.StringUtils;
|
||||
|
|
@ -55,6 +54,7 @@ public class RedisConfiguration extends CachingConfigurerSupport {
|
|||
AssertUtil.invalidate(StringUtils.isEmpty(address), "redisson 配置错误");
|
||||
// 使用单机模式
|
||||
config.useSingleServer()
|
||||
.setClientName(redissonProperties.getClientName())
|
||||
//设置redis key前缀
|
||||
.setNameMapper(new KeyPrefixHandler(redissonProperties.getPrefix()))
|
||||
.setTimeout(redissonProperties.getTimeout())
|
||||
|
|
@ -77,6 +77,7 @@ public class RedisConfiguration extends CachingConfigurerSupport {
|
|||
config.useClusterServers()
|
||||
//设置redis key前缀
|
||||
.setNameMapper(new KeyPrefixHandler(redissonProperties.getPrefix()))
|
||||
.setClientName(redissonProperties.getClientName())
|
||||
.setTimeout(redissonProperties.getTimeout())
|
||||
.setPassword(redissonProperties.getPassword())
|
||||
.setUsername(redissonProperties.getUsername())
|
||||
|
|
@ -93,6 +94,7 @@ public class RedisConfiguration extends CachingConfigurerSupport {
|
|||
}
|
||||
config.useSentinelServers()
|
||||
.setNameMapper(new KeyPrefixHandler(redissonProperties.getPrefix()))
|
||||
.setClientName(redissonProperties.getClientName())
|
||||
.setTimeout(redissonProperties.getTimeout())
|
||||
.setUsername(redissonProperties.getUsername())
|
||||
.setPassword(redissonProperties.getPassword())
|
||||
|
|
|
|||
|
|
@ -2,16 +2,10 @@ package com.chushang.redis.config.properties;
|
|||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.redisson.config.ClusterServersConfig;
|
||||
import org.redisson.config.ReadMode;
|
||||
import org.redisson.config.SentinelServersConfig;
|
||||
import org.redisson.config.SubscriptionMode;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @auther: zhao
|
||||
* @date: 2024/4/29 15:52
|
||||
|
|
@ -19,7 +13,7 @@ import java.util.List;
|
|||
@Data
|
||||
@RefreshScope
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "redis.config")
|
||||
@ConfigurationProperties(prefix = "config.redis")
|
||||
public class RedissonProperties {
|
||||
|
||||
private String prefix;
|
||||
|
|
|
|||
|
|
@ -7,17 +7,29 @@ server:
|
|||
tomcat:
|
||||
uri-encoding: UTF-8
|
||||
threads:
|
||||
max: 200
|
||||
min-spare: 25
|
||||
max: 800
|
||||
min-spare: 100
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
# 如果需要使用读写分离, 此处需要改造, 有没有办法不用改?
|
||||
datasource:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: ${conf.jdbc.cacc.master.username}
|
||||
password: ${conf.jdbc.cacc.master.password}
|
||||
url: jdbc:mysql://${conf.jdbc.cacc.master.host}:${conf.jdbc.cacc.master.port}/${conf.jdbc.cacc.master.database}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
|
||||
username: ${conf.jdbc.cs.master.username}
|
||||
password: ${conf.jdbc.cs.master.password}
|
||||
url: jdbc:mysql://${conf.jdbc.cs.master.host}:${conf.jdbc.cs.master.port}/${conf.jdbc.cs.master.database}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
|
||||
hikari:
|
||||
# 最大线程池数量
|
||||
maximum-pool-size: 30
|
||||
# 最小线程池数量
|
||||
minimum-idle: 5
|
||||
# 检测连接
|
||||
connection-test-query: SELECT 1
|
||||
# 连接超时时间 默认30分钟
|
||||
connection-timeout: 30000
|
||||
# 连接最大生存期间, 默认30分钟
|
||||
#max-lifetime: 300000
|
||||
devtools:
|
||||
restart:
|
||||
enabled: true
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
server:
|
||||
tomcat:
|
||||
uri-encoding: UTF-8
|
||||
threads:
|
||||
max: 200
|
||||
min-spare: 25
|
||||
connection-timeout: 5000ms
|
||||
spring:
|
||||
config:
|
||||
import:
|
||||
-: "classpath:application.yml"
|
||||
cloud:
|
||||
loadbalancer:
|
||||
cache:
|
||||
|
|
@ -23,7 +19,7 @@ spring:
|
|||
server-addr: ${spring.cloud.nacos.discovery.server-addr}
|
||||
namespace: ${spring.cloud.nacos.discovery.namespace}
|
||||
group: ${spring.cloud.nacos.discovery.group}
|
||||
file-extension: yml
|
||||
file-extension: yaml
|
||||
refresh-enabled: true
|
||||
prefix: ${spring.application.name}
|
||||
shared-configs:
|
||||
|
|
|
|||
Loading…
Reference in New Issue