mybatis不想使用 $ 符号来动态传递列参数

可以考虑使用 MyBatis 的 <choose><when> 和 <otherwise> 标签来实现类似的功能。

<select id="selectUsers" parameterType="map" resultType="com.example.model.User">  
    SELECT  
    <choose>  
        <when test="columns != null and columns.contains('id')">  
            id,  
        </when>  
        <when test="columns != null and columns.contains('name')">  
            name,  
        </when>  
        <when test="columns != null and columns.contains('age')">  
            age,  
        </when>  
        <otherwise>  
            *  
        </otherwise>  
    </choose>  
    FROM user  
    <if test="conditions != null">  
        WHERE ${conditions}  
    </if>  
</select>