EL1007E: Property or field 'tenantId' cannot be found on null

Blade 未结 2 664

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

由于本地配置了多数据源,通过dynamic-datasource-spring-boot-starter进行数据源切换。其他使用正常。但是进行加载NoticeController相关业务处理。就出现这个Property or field 'tenantId' cannot be found on null 。

图片.png


2. 通过查看手册,开启数据库隔离配置之后

图片.png


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


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

BladeX-Boot.2.8.1RELEASE

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

出现如下问题

项目加载器启动中途失败,项目停止运行


***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springblade.core.tenant.config.TenantDataSourceConfiguration.dataSource(TenantDataSourceConfiguration.java:91)

The following method did not exist:

    com.baomidou.dynamic.datasource.DynamicRoutingDataSource.setProvider(Lcom/baomidou/dynamic/datasource/provider/DynamicDataSourceProvider;)V

The method's class, com.baomidou.dynamic.datasource.DynamicRoutingDataSource, is available from the following locations:

    jar:file:/F:/Repository/Maven_Repository/com/baomidou/dynamic-datasource-spring-boot-starter/3.5.0/dynamic-datasource-spring-boot-starter-3.5.0.jar!/com/baomidou/dynamic/datasource/DynamicRoutingDataSource.class

It was loaded from the following location:

    file:/F:/Repository/Maven_Repository/com/baomidou/dynamic-datasource-spring-boot-starter/3.5.0/dynamic-datasource-spring-boot-starter-3.5.0.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of com.baomidou.dynamic.datasource.DynamicRoutingDataSource

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

2条回答
  • 2022-09-14 10:23


    @TenantDS在controller里把这注解注释掉就可以了

    1 讨论(0)
  • 2022-06-27 18:04

    调用的Notice模块哪个接口,看报错是无法获取tenantId的值,调用接口的时候确认下有没有传递token。

    如果没有传递token则无法切换,因为系统鉴权是无状态模式,需要通过传递的token才知道用户的身份,才能获取到tenantId来切换,没有的话就会报错。

    所以你需要描述的更加详细一些,具体调用的是哪个接口,调用时参数是什么,这样才能方便我们来进行调试排查

    作者追问:2022-06-28 11:15

    您好,请求公告栏的的list接口,会出现该问题。请求信息如下:

    图片.png

    后端

    图片.png

    请求信息

    图片.png


    图片.png


    0 讨论(0)
提交回复