把#改为mybaties可识别的变量${}就可以了 如下:

原注解

@Select(SELECT * FROM users WHERE city = #{cityId} ORDER BY #{byName}) 

修改后

@Select(SELECT * FROM users WHERE city = #{cityId} ORDER BY ${byName}) 

注:kotlin需要用\来转义$符号