Here my spring configurer:
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled=true)
@Slf4j
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
log.info("Web security performing");
http
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.cors().and()
.csrf().disable()
.authorizeRequests().anyRequest().permitAll();
log.info("Web security performed");
}
}
Nevertheless, it's never reached.
Here my application class:
@ComponentScan({
"cat.gencat.catsalut.hes.core.domain.mpi",
"cat.gencat.catsalut.hes.core.repository"
})
@SpringBootApplication(exclude = JmxAutoConfiguration.class)
public class ProjectApplication {
As you can see, @ComponentScan is placed on main ProjectApplication class.
I've realized that when I remove @ComponentScan from my main ProjectApplication class, my WebSecurityConfiguration is detected.
When it's present, WebSecurityConfiguration is ignored.
Any ideas?
SpringBootApplicationwithout specifying@ComponentScanby default scan all classes in the current and those that are located in subpackages for pickingBeansandConfigurationand other stuffs. if you specifythen only
cat.gencat.catsalut.hes.core.domain.mpiandcat.gencat.catsalut.hes.core.repositoryand their subpackages will be scanned for beans. so try to put the class which contains@SpringBootApplicationin the root of your project or use@SpringBootApplication(scanBasePackages = {'package1', 'package2'})to specify packages that have to be scanned.