MyBatis遇到问题
1、根据主键查询时候 shipperMapper.selectByPrimaryKey(uid),报错
是因为主键没有设置@Id
解决:在主键上设置@Id,错误解决
2019-12-18 09:41:22,453 [http-nio-8670-exec-8] ERROR adminLogger -[ExceptionHandlerAdvice.java:67]- 运行异常 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='accountStatus', mode=IN, javaType=class java.lang.Integer, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #11 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) at com.sun.proxy.$Proxy119.selectOne(Unknown Source)
2、出现以下问题,是包导入错了,
正确的 import org.apache.ibatis.annotations.Param; 错误的 import io.lettuce.core.dynamic.annotation.Param;
Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'params' in 'class com.health.model.BpUser' at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:419) at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:164) at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:162) at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:49) at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:122) at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextMap.get(DynamicContext.java:94) at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextAccessor.getProperty(DynamicContext.java:108) at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:2685) at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:114) at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)