项目场景:
ruoyi-cloud进行Mybatis转换Mybatis-plus,执行QueryWrapper方法,一直提醒报错 Cause: java.sql.SQLSyntaxErrorException: Unknown column ‘search_value’ in ‘field list’
但是对应实体类没有查找到这个字段,经过一番努力,在一篇文章里找到了答案,最后问题得到了解决!
### The error may involve defaultParameterMap ### The error occurred while setting parameters ### SQL: SELECT category_id,category_name,code,app_type,remark,del_flag,search_value,create_by,create_time,update_by,update_time,params FROM wf_category WHERE del_flag='0' ### Cause: java.sql.SQLSyntaxErrorException: Unknown column 'search_value' in 'field list' ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Unknown column 'search_value' in 'field list' at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:239) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) at com.sun.proxy.$Proxy111.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForIPage(MybatisMapperMethod.java:121) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:85) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) at com.sun.proxy.$Proxy162.selectPage(Unknown Source) at com.ruoyi.common.core.mapper.BaseMapperPlus.selectVoPage(BaseMapperPlus.java:183) at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$DefaultMethodInvoker.invoke(MybatisMapperProxy.java:162) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) at com.sun.proxy.$Proxy162.selectVoPage(Unknown Source)
同时要去掉 mybatis-spring-boot-starter的mybatis ,否则版本可能会有冲突
<!-- SpringBoot集成mybatis框架 --> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>${mybatis-spring-boot.version}</version> <exclusions> <exclusion> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> </exclusion> </exclusions> </dependency>