首页 > 解决方案 > 我可以将 Spring Boot 组件“自动装配”到 MyBatis 查询吗?

问题描述

例如,这是一个示例查询:

<select id="selectCouponCodes" resultType="SomeDao">
  select *
  from temp_table
  where code = #{code}
</select>

通常,我会将code参数传递给 Mybatis 映射器。但是有很多查询使用相同的code,所以我正在寻找一个不使用参数的快捷方式。像这样的东西:

<select id="selectCouponCodes" resultType="SomeDao">
  select *
  from temp_table
  where code = #{$SomeComponent.code}
</select>

$SomeComponent不是从参数传递的。相反,它是“自动装配”到查询的。有没有办法让这成为可能?如果这是不可能的,任何替代方案将不胜感激。

标签: spring-bootmybatisspring-mybatis

解决方案


推荐阅读