在Mybatis中,@Select注解可以使用参数来传递参数。有两种方式可以传递参数:
直接在@Select注解中使用#{}来引用参数名,例如:@Select("SELECT * FROM users WHERE id = #{userId}")User getUserById(int userId);使用@Param注解来指定参数名,然后在@Select注解中引用参数名,例如:@Select("SELECT * FROM users WHERE id = #{userId}")User getUserById(@Param("userId") int userId);这样就可以在@Select注解中传递参数。需要注意的是,在使用@Param注解时,需要注意参数名与@Param注解中的value值要一致。


