Custom security is not working when extending the WebSecurityConfigurerAdapter class in different package

前端 未结 1 1492
感情败类
感情败类 2021-01-17 19:51

I have extendend WebSecurityConfigurerAdapter in a different package other than the package containing class for @SpringBootApplication. Then it\'s

相关标签:
1条回答
  • 2021-01-17 20:19

    @SpringBootApplication is a short hand for @Configuration, @EnableAutoConfiguration, @ComponentScan. This makes Spring to do componentscan for the current packages and packages below this. So all classes in com.example and under com.example are scanned for bean creation while not any others above com.example like com.securitymodule

    Hence either add @ComponentScan(basePackages = {"com.securitymodule"}) into your main class, or make the package of WebSecurityConfigurerAdapter as com.example.securitymodule

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