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;
}
后续在使用过程中碰到的问题持续更新!