1.在类中定义静态常量
package com.model;
public class Demo{
public static String MYSQL_ENCRYPT_KEY="静态常量";
}
2.在mybatis中引用静态常量
<select id="GetUserNameByID" resultType="HashMap">
select CAST(AES_DECRYPT(UNHEX(Name),'${@com.model.Demo@MYSQL_ENCRYPT_KEY}') as char)as Name1 from users as temp where ID=#{ID}
</select>
3.mybatis中使用'${@类的路径@常量名称}'来引用常量