多租户SAAS 新建数据库和表后 admin登录查询报错?

Blade 未结 2 928
张亚林
张亚林 剑圣 2021-06-09 17:17

一、该问题的重现步骤是什么?

1. 最新版bladex-boot 开启多租户模式。

2. 新建一个租户库 bladex-boot-00000  拷贝 blade-notice,blade-tenant 两张表到新库中。

3.admin登录 点击通知公告 博客管理等节点报错


二、你期待的结果是什么?实际看到的又是什么?

期待的结果

(1):创建租户如果要数据库隔离,能否自动生成数据库及相应的 有租户数据的表?

(2):如果指定了租户的库,能否处理下如果该库下有表就读取该库下的表,否则去主库读取?


三、你正在使用的是什么产品,什么版本?在什么操作系统上?


bladex-boot  最新版   windows 10


四、请提供详细的错误堆栈信息,这很重要。

--点击通知公告报错

nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [select resource_code, scope_column, scope_field, scope_type, scope_value from blade_scope_data where scope_class = ? and id in (select scope_id from blade_role_scope where scope_category = 1 and role_id in (?))]; nested exception is java.sql.SQLSyntaxErrorException: Table 'bladex_boot_saber_000000.blade_scope_data' doesn't exist ### Cause: org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [select resource_code, scope_column, scope_field, scope_type, scope_value from blade_scope_data where scope_class = ? and id in (select scope_id from blade_role_scope where scope_category = 1 and role_id in (?))]; nested exception is java.sql.SQLSyntaxErrorException: Table 'bladex_boot_saber_000000.blade_scope_data' doesn't exist

--点击博客管理报错

nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [select resource_code, scope_column, scope_field, scope_type, scope_value from blade_scope_data where scope_class = ? and id in (select scope_id from blade_role_scope where scope_category = 1 and role_id in (?))]; nested exception is java.sql.SQLSyntaxErrorException: Table 'bladex_boot_saber_000000.blade_scope_data' doesn't exist ### Cause: org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [select resource_code, scope_column, scope_field, scope_type, scope_value from blade_scope_data where scope_class = ? and id in (select scope_id from blade_role_scope where scope_category = 1 and role_id in (?))]; nested exception is java.sql.SQLSyntaxErrorException: Table 'bladex_boot_saber_000000.blade_scope_data' doesn't exist


五、若有更多详细信息,请在下面提供。

2条回答
  • 2021-06-09 17:30

    image.png

    多租户·配置数据源


    回答: 2021-06-09 17:31

    image.png

    回答: 2021-06-10 10:57

    群主没解决我的问题,那如果我要给每个用户分库,要怎么做才能不报错,另外相关的表如果我拷贝一份,如何保证多个数据库和主库数据同步?

    0 讨论(0)
  • 2021-06-09 21:49

    1)目前不能自动创建,需要手动创建,如果用户提的需求后续做的差不多了,会考虑做自动创建功能

    2)每次请求都要走拦截器,如果做这样高频的数据库表存在判断会对性能造成很大的影响,所以这个方法不可取。

    0 讨论(0)
提交回复