Java 通过MyBatis拦截器添加当前用户会话数据作为全局参数

Java 通过MyBatis拦截器添加当前用户会话数据作为全局参数,java,spring,spring-security,mybatis,spring-mybatis,Java,Spring,Spring Security,Mybatis,Spring Mybatis,我想在执行myBatis查询时传递用户会话数据(用户ID、IP、用户名、电子邮件和/或权限等) 我知道我能够添加全局变量。然而,我得到了错误。它假设我的全局参数是模型的一个变量。如何传递值并获取和使用它 @Intercepts({@Signature( type= Executor.class, method = "query", args = {MappedStatement.class, Object.class})}) public

我想在执行myBatis查询时传递用户会话数据(用户ID、IP、用户名、电子邮件和/或权限等)

我知道我能够添加全局变量。然而,我得到了错误。它假设我的全局参数是模型的一个变量。如何传递值并获取和使用它

    @Intercepts({@Signature(
        type= Executor.class,
        method = "query",
        args = {MappedStatement.class, Object.class})})
public class ConfigPropInterceptor implements Interceptor {

    private final Map<String, Object> properties = new HashMap<String, Object>();

    public Object intercept(Invocation invocation) throws Throwable {
        Object param = invocation.getArgs()[1];
        MappedStatement ms = (MappedStatement) invocation.getArgs()[0];
        Configuration configuration = ms.getConfiguration();
        configuration.getVariables().put("param", "value");

    return invocation.proceed();

    }
} 

尝试删除
parameterType=“City”
它不起作用。
<insert id="insertCity" parameterType="City" useGeneratedKeys="true" keyProperty="id">
    insert into city(name, state, country) values("${param}",#{state},#{country})
</insert>
There was an unexpected error (type=Internal Server Error, status=500).
nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'param' in 'class com.project.data.model.City'