-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
多数据源配置方言不生效 #842
Comments
我上面的截图中是指定了mysql就不会报错,能正常查询,但是我设置为oracle或者注销掉那一行就会报错 |
还有我看网上说的需要把true改为字符在这种“true”,我也试过,包括这些配置属性用下划线的方式命名,各种能试的方式全都试过了,可谓是找遍全网花了我整整两天时间,最终还是解决不了这个问题 |
刚好也碰到了多数据源的分页问题,我这边试了一下设置了插件配置是可以解决问题的,你还是不行的话可能需要debug看下是不是配置没生效。
pagehelper:
autoRuntimeDialect: true
public void setProperties(Properties properties) {
//初始化自定义AutoDialect
initAutoDialectClass(properties);
//使用 sqlserver2012 作为默认分页方式,这种情况在动态数据源时方便使用
String useSqlserver2012 = properties.getProperty("useSqlserver2012");
if (StringUtil.isNotEmpty(useSqlserver2012) && Boolean.parseBoolean(useSqlserver2012)) {
registerDialectAlias("sqlserver", SqlServer2012Dialect.class);
registerDialectAlias("sqlserver2008", SqlServerDialect.class);
}
initDialectAlias(properties);
//指定的 Helper 数据库方言,和 不同
String dialect = properties.getProperty("helperDialect");
//运行时获取数据源
String runtimeDialect = properties.getProperty("autoRuntimeDialect");
//1.动态多数据源
if (StringUtil.isNotEmpty(runtimeDialect) && "TRUE".equalsIgnoreCase(runtimeDialect)) {
this.autoDialect = false;
this.properties = properties;
}
//2.动态获取方言
else if (StringUtil.isEmpty(dialect)) {
autoDialect = true;
this.properties = properties;
}
//3.指定方言
else {
autoDialect = false;
this.delegate = instanceDialect(dialect, properties);
}
}
|
刚好也碰到了多数据源的分页问题,我这边试了一下设置了插件配置是可以解决问题的,你还是不行的话可能需要debug看下是不是配置没生效。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
我们项目用的是pagehelper6.1.0,用的是双数据源,我在mappr层用mybatis的@ds注解,mybatis可以正确的选择使用的数据源,但是pagehelper一直按照我都主数据源方言进行分页,我的主数据源是oracle,从数据源是doris,但是用的mysql驱动进行连接的,每次分页查询doris的时候就因为分页方言不对报错
The text was updated successfully, but these errors were encountered: