hasAuthority Spring doesn't work

Hi I have replaced the default permission evaluator but now it just makes the hasAuthority not working (I am using the same example as the ones on google but it doesn't work with me)
@Bean
fun expressionHandler(@Autowired permissionEvaluator: CustomPermissionEvaluator,
                      @Autowired roleHierarchy: RoleHierarchy): MethodSecurityExpressionHandler {
    val handler = DefaultMethodSecurityExpressionHandler()
    handler.setPermissionEvaluator(permissionEvaluator)
    handler.setRoleHierarchy(roleHierarchy)

    return handler
}


Here is my error Property or field 'hasAuthority' cannot be found on object of type 'org.springframework.security.access.expression.method.MethodSecurityExpressionRoot' - maybe not public or not valid?
Was this page helpful?