SpringBoot + method based hierarchical roles security: ServletContext is required

后端 未结 1 790
遥遥无期
遥遥无期 2021-01-28 08:31

I added method-based security and added role hierarchy. I keep getting the following exception during build:

org.springf

相关标签:
1条回答
  • 2021-01-28 08:41

    OK, found it.

    I played around with the class annotations and came to a simple solution: I removed @EnableGlobalMethodSecurity from GlobalMethodSecurityConfig and moved it to WebSecurityConfiguration, where it was before. So it looks like this:

    @Configuration
    @EnableWebSecurity
    @EnableGlobalMethodSecurity(prePostEnabled = true)
    public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter { (...) }
    

    and this:

    @Configuration
    public class GlobalMethodSecurityConfig extends GlobalMethodSecurityConfiguration { (...) }
    

    The most interesting part is that the accepted answer from here advises what didn't work for me.

    0 讨论(0)
提交回复
热议问题