mybatis链接数据库mysql8.0 Cause: java.sql.SQLDataException: Cannot determine value type from string 'id'

错误:

org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.sql.SQLDataException: Cannot determine value type from string 'id'
### The error may exist in mybatis/user.xml
### The error may involve user.getUserById-Inline
### The error occurred while setting parameters
### SQL: SELECT 'id',          'username',          'birthday',          'sex',          'address'          FROM user WHERE id=?
### Cause: java.sql.SQLDataException: Cannot determine value type from string 'id'

    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:111)
错误原因:查询不当

<select id="getUserById" parameterType="int" resultType="com.mybatis.pojo.User">
        SELECT 'id',
         'username',
         'birthday',
         'sex',
         'address'
         FROM user WHERE id=#{id1}

    </select>

应改为:

<select id="getUserById" parameterType="int" resultType="com.mybatis.pojo.User">
        SELECT * FROM user WHERE id=#{id1}
    </select>

猜你喜欢

转载自blog.csdn.net/dagedeshu/article/details/87930197