Mybatis错误(一)Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException:

Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.apache.ibatis.reflection.ReflectionException:Error instantiating class domain.User with invalid types () or values (). Cause: java.lang.NoSuchMethodException: domain.User.<init>()
### The error may exist in mapper/UserMapper.xml
### The error may involve mapper.UserMapper.selectUser-Inline
### The error occurred while setting parameters
### SQL: SELECT * FROM TB_USER WHERE id=?
### Cause: org.apache.ibatis.reflection.ReflectionException: Error instantiating class domain.User with invalid types () or values (). Cause: java.lang.NoSuchMethodException: domain.User.<init>()

at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26)



黑体部分提示的问题在于,你的POJO对象没有空参构造器,一定要申明你的普通对象加入空参构造器

你需要知道,在JAVA中,如果你设置了有参构造器,默认提供的空参构造器就默认没有了

猜你喜欢

转载自blog.csdn.net/xinjieyuan/article/details/76038517