【发布时间】:2020-02-06 01:52:04
【问题描述】:
我的应用程序中有多个不同类型的用户,每种类型都有自己的角色(显然还有权限)
我想使用 spring data rest,但此功能必须仅适用于 ADMIN_ROLE 用户。
然后我为每个实体创建了 2 个存储库,一个用于管理员,另一个用于其余用户:
@RepositoryRestResource(exported = false)
public interface MenuRepository extends JpaRepository<Menu, Integer> {
}
// -------------------------------------------------------------------
@RepositoryRestResource
@PreAuthorize("hasRole('ROLE_ADMIN')")
public @interface AdminRestRepository {
}
// -------------------------------------------------------------------
@AdminRestRepository
public interface AdminMenuRestRepository extends JpaRepository<Menu, Integer> {
}
问题是,一旦我启动应用程序,有时存储库会被导出,而其他时候却没有......任何线索?
【问题讨论】:
标签: spring spring-boot spring-security java-8 spring-data-jpa