首页 > 解决方案 > Spring boot Restcontroller @RoleAllowed 在接口实现中不起作用

问题描述

我创建了一个带有默认方法的接口,该方法定义了@RequestMappingand@RoleAllowed并在其中实现Restcontroller。但是该@RoleAllowed属性不是从默认方法说话的。PFB 代码

public interface Resource{
@REquestMapping(value="/api/test",method=RequestMethod.GET)
@RoleAllowed({"READ_ONLY"})
default public String testEndPoint(){
  return "defaultmethod";
}

}

public class ResourceImpl implements Resource{

@override
public String testEndPoint(){
  return "ResourceImpl";
}
}

}

@RoleAllowed不工作ResourceImpl。如果我没有覆盖testEndPoint方法,它工作正常

标签: spring-bootspring-security

解决方案


推荐阅读