2021
04-27
04-27
解决Mybatis-plus和pagehelper依赖冲突的方法示例
简介MyBatis-Plus(简称MP)是一个 MyBatis 的增强工具,在MyBatis的基础上只做增强不做改变,为简化开发、提高效率而生。启动即会自动注入基本CURD,性能基本无损耗,直接面向对象操作Mybati-plus本身自带分页功能,但是我个人一直是使用pagehelper进行分页,所以在pom中添加了pagehelper依赖,但是运行项目后发现jar包冲突,面对冲突我们应该怎么解决它呢,看完如下内容便可轻松解决先看依赖<!--mbatis-p...
继续阅读 >
错误描述Anattemptwasmadetocallamethodthatdoesnotexist.Theattemptwasmadefromthefollowinglocation:com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder.getLanguageDriver(MybatisMapperAnnotationBuilder.java:369)Thefollowingmethoddidnotexist:com.baomidou.mybatisplus.core.MybatisConfiguration.getLanguageDriver(Ljava/lang/Class;)Lorg/apache/ibatis/scripting/LanguageDriver;...
背景在分表的背景下,有时候查询数据的时候需要跨表查询,那此时就需要MP在解析的时候,能够很好的自适应表格名称实现MP中是通过PaginationInterceptor(分页插件)完成动态表名解析的,配置如下:数据库中表依赖<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.3.1.tmp</version></dependency>配置类packagecom.huanchuang.common.config;importcom.baomidou.myba...
1.引入mybatis-plus相关包,pom.xml文件2.配置文件application.property增加多库配置mysql数据源配置spring.datasource.primary.jdbc-url=jdbc:mysql://xx.xx.xx.xx:3306/portal?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&characterEncoding=utf8&serverTimezone=GMT%2B8spring.datasource.primary.username=rootspring.datasource.primary.password=rootspring...
在使用mybatis或者其它mybatis的二次开发框架时(例如mybatis-plus),有时候数据库中的字段和实体类中的字段可能不一致。例如数据库中只有3个字段,而实体类中除了数据库中对应映射的三个字段以外还有多余的其余字段,例如实体类中有5个字段。那么运行就会报错如果需要在mybatis映射实体类中加入非数据库映射字段。那么可以使用@TableField(exist=false)进行标识对应字段不属于数据库的映射字段即可。当然可以点击进入@TableFi...
1:先检查字段有没有加上注解@TableField(fill=FieldFill.INSERT_UPDATE)@TableField(fill=FieldFill.INSERT_UPDATE)privateDateupdatedTime;2:有没有实现MetaObjectHandler接口,并且加入到Spring容器中@ComponentpublicclassMyMetaObjectHandlerimplementsMetaObjectHandler{@OverridepublicvoidinsertFill(MetaObjectmetaObject){this.strictInsertFill(metaObject,"createdTime",Date.class,new...
mybatis-plus判断null或者匹配固定值wrapper.lambda().and(wrapper1->wrapper1.isNull(MaterialInfoDO::getCompanyId).or().eq(MaterialInfoDO::getCompanyId,"ABC");补充:Mybatis-plus查询时某些字段为null在网站上搜索得到的是mybatis配置中需要添加一段配置驼峰命名法mybatis:configuration:map-underscore-to-camel-case:true但在公司项目中这个配置是已经配置的了,经过测试还是无法获取正确的值经过自己查看代码后...