MyBatis-Plus使用小插曲

1、解决项目使用MP插件SqlServer数据库批量插入list报错的问题。

问题描述:

org.apache.ibatis.exceptions.PersistenceException: 
### Error flushing statements.  Cause: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: The statement must be executed before any results can be obtained.
### Cause: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: The statement must be executed before any results can be obtained.

问题解决:重写saveBatch和saveOrUpdateBatch(缺点是批量添加不能返回id,对于不需要返回id的场景适用),并将Jdbc3KeyGenerator替换为NoKeyGenerator(当前影响版本全部)。

2、Dubbo使用MP插件的Wrapper传参引起的错误。

问题描述:

Failed to invoke the method count in the service com.zhenhe.data.service.website.WebsiteBusinessService. Tried 3 times of the providers [192.168.150.191:20880] (1/1) from the registry nacos.dev.zhenheyiliao.cn:80 on the consumer 192.168.150.191 using the dubbo version 2.7.21. Last error is: Failed to invoke remote method: count

问题解决:不建议使用wrapper进行传参,数据太重导致接受失败,建议定义对应的DTO传输。

3、Shiro使用MP的MetaObjectHandler元数据处理器在需要登录的情况下报错。

问题描述:

UnavailableSecurityManagerException

问题解决:在shiroConfig配置文件中注入下面bean

@Bean
    public MethodInvokingFactoryBean methodInvokingFactoryBean(SecurityManager securityManager) {
        MethodInvokingFactoryBean bean = new MethodInvokingFactoryBean();
        bean.setStaticMethod("org.apache.shiro.SecurityUtils.setSecurityManager");
        bean.setArguments(securityManager);
        return bean;
    }

后续在使用过程中碰到的问题持续更新!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值