Assuming that my Spring Security and properties are configured properly, I would like to use role name from property like
@PreAuthorize("hasRole('${role.rolename}')")
public void method() {}
I have tried like in above code sample but it does not work (it takes '${role.rolename}' String as role to compare)
If I switch to
@PreAuthorize("hasRole('ROLE_ADMIN')")
public void method() {}
it works just fine.
My motivation to such usage is better flexibility in application tests on various environments.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…