温馨提示×

properties在mybatis中的引用方式

小樊
82
2024-08-18 23:33:38
栏目: 深度学习

在MyBatis中,可以通过以下方式引用属性:

  1. 在Mapper XML文件中使用${}占位符来引用属性,例如:
<select id="selectUser" parameterType="int" resultType="User">
    SELECT * FROM users WHERE id = ${userId}
</select>
  1. 在Java代码中使用@Value注解来引用属性,例如:
@Value("${mybatis.mapperLocations}")
private String mapperLocations;
  1. 在MyBatis配置文件中使用${}占位符来引用属性,例如:
<properties resource="mybatis-config.properties"/>

0