一、该问题的重现步骤是什么?
1. 配置多数据源
2. debug报错
nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### 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 com.microsoft.sqlserver.jdbc.SQLServerException: 对象名 'blade_scope_data' 无效。\r\n### 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 com.microsoft.sqlserver.jdbc.SQLServerException: 对象名 'blade_scope_data' 无效。
二、你期待的结果是什么?实际看到的又是什么?
期待不报错,网上搜不到解决办法
三、你正在使用的是什么产品,什么版本?在什么操作系统上?
bladex,Windows11
四、请提供详细的错误堆栈信息,这很重要。
nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### 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 com.microsoft.sqlserver.jdbc.SQLServerException: 对象名 'blade_scope_data' 无效。\r\n### 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 com.microsoft.sqlserver.jdbc.SQLServerException: 对象名 'blade_scope_data' 无效。
五、若有更多详细信息,请在下面提供。
用的是bladex的cloud版本么?如果是cloud,则需要先在bladex根目录执行 mvn clean install,然后业务服务引入 blade-starter-data-scope依赖,这样就会走master库了
这个问题是突然出现的,我在本地跑项目,换了多数据源的SQLserver配置的数据库名,重新跑项目,跑完项目再切换回原来SQLserver配置的数据库,就不会报这个错误了。但是过段时间还是会报这个错误。项目中引入的
blade-starter-datascope
依赖。看项目结构用的不像是cloud
清空redis再启动试试看
请问你解决了吗
扫一扫访问 Blade技术社区 移动端