There is no getter for property named 'userIds' in 'class java.lang.String'
org.mybatis.spring.MyBatisSystemException: nested exception isorg.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'userIds' in 'class java.lang.String'
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)
at $Proxy23.update(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:246)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:25)
at $Proxy30.deleteUser(Unknown Source)
at com.hailong.midea.busi.user.manager.UserManager.deleteUser(UserManager.java:80)
at com.hailong.midea.web.controller.user.UserController.deleteUser(UserController.java:147)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:594)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1365)
at com.hailong.midea.web.filter.SessionFilter.doFilterInternal(SessionFilter.java:80)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1336)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
at org.eclipse.jetty.server.Server.handle(Server.java:351)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:451)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:931)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:857)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:76)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:609)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:45)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
at java.lang.Thread.run(Thread.java:662)
Caused by:
org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'userIds' in 'class java.lang.String'
at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:308)
at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:93)
at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:134)
at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:27)
at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:103)
at org.apache.ibatis.builder.xml.dynamic.DynamicContext$ContextMap.get(DynamicContext.java:72)
at org.apache.ibatis.builder.xml.dynamic.DynamicContext$ContextAccessor.getProperty(DynamicContext.java:90)
at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1657)
at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:92)
at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)
at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:333)
at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:413)
at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:454)
解決方案一:
引起問題的原因是因為在DAO方法中定義的引數 與 實體中定義的屬性不一致 導致的,
比如DAO方法定義的是:
public int deleteUser(String userIds);
SQL語句如下:
<!-- 刪除使用者(邏輯刪除) -->
<update id="deleteUser" parameterType="String">
UPDATE t_user t SET t.user_status = '禁用' WHERE t.user_pk_id IN(#{userIds})
</update>
UserEntity的定義:
public class UserEntity extends AbstractEntity{
private int userPkId;
private String userId;
private String userName;
private String sex;
private byte age;
}
這個userIds並不在UserEntity中存在,而userId是存在的,如果使用UserEntity中不存在userIds的屬性 所以會報此錯誤。改成userId 問題即可解決。
解決方案二:
出現原因
這裡出現的問題是在DAO方法中定義的引數 與 實體中定義的屬性不一致
導致的。
解決方案:
dao層加@Param("userIds")註解即可
public List<DictItem> selectKeyByUserId(@Param("userIds") long userIds);
相關文章
- MyBatisSystemException There is no getter for property named 'id' in 'class java.lang.String'MyBatisExceptionJava
- mybatis There is no getter for property named 'xx' in 'class java.lang.String 沒有寫 xinwen.setsavetypeMyBatisJava
- javax.el.PropertyNotFoundException:Property 'statisDate' not found on type java.lang.StringJavaException
- MyBatis對映錯誤:There is no setter for property named xxxMyBatis
- Mybatis單個引數的if判斷(針對異常:There is no getter for property..)MyBatis
- getter概念
- spring-mybatis整合:NoSuchBeanDefinitionException: No bean named 'xxx.class' availableSpringMyBatisBeanExceptionAI
- 理解defineProperty以及getter、setter
- javascript 中的getter,setterJavaScript
- java.lang.String 與stringJava
- 私有setter公有getter屬性
- VUEX 使用學習五 : getterVue
- vuex核心概念---action、getter、moduleVue
- laravel named routeLaravel
- Request: credentials property
- Property屬性
- golang自動生成setter和getterGolang
- vuex 原始碼:深入 vuex 之 getterVue原始碼
- Vue引發的getter和setterVue
- 小事: 自動生成Getter程式碼
- JavaScript中getter/setter的實現JavaScript
- ImportError: No module named `defusedxml`ImportErrorXML
- ImportError: No module named yamlImportErrorYAML
- ImportError: No module named utilsImportError
- ModuleNotFoundError: No module named 'sqlite'ErrorSQLite
- ImportError: No module named cElementTreeImportError
- 【JAVA】筆記(8)--- java.lang.String 精講Java筆記
- [Vuex系列] - Vuex中的getter的用法Vue
- 【譯】6. Java反射——Getter和SetterJava反射
- iOS面試之@propertyiOS面試
- 類的property特性
- vue-property-decoratorVue
- Objective-C PropertyObject
- [Javascript] Object property orderJavaScriptObject
- No bean named BookServiceImpl availableBeanAI
- CentOS 7 named配置forwardCentOSForward
- ModuleNotFoundError: No module named 'pyttsx'ErrorTTS
- ImportError: No module named torchvisionImportError