我有一个Spring Security应用程序,其中要启用注释安全性(授权前和授权后)。我也有一个小型示例应用程序,已经在其中实现了它。一切正常。但是将配置移至主要应用程序失败。控制台中没有错误。但是注释不起作用。看来,它们根本没有被阅读。所有配置和组件版本都完全相同。
有
<security:global-method-security secured-annotations="enabled" />
以安全上下文和servlet上下文记录。但是,在主应用程序中,@ Controller方法和@Service方法都没有通过注释来保证安全。
我该如何调试?
已解决!
从
您可能需要pre-post-annotations =“ enabled”,并且已设置expressionHandler。
确保标签
logging.level.org.springframework.security: DEBUG
或添加到application.properties
:
logging.level.org.springframework.security=DEBUG
或通过WebSecurityConfig
添加到EnableWebSecurity
批注debug = true
:
@Configuration
@EnableWebSecurity(debug = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
// ...
}