java - Filter invoke twice when register as Spring bean -
i want use @autowire filter . define filter in securityconfig below: @override protected void configure(httpsecurity http) throws exception { http.sessionmanagement().sessioncreationpolicy(sessioncreationpolicy.stateless); http.addfilterbefore(geta(), basicauthenticationfilter.class); http.csrf().disable(); } @bean public geta(){ return new a(); } this filter a extends spring's genericfilterbean . i below output when invoke controller, shows filter hits twice. filter before filter before mycontroller invoke filter after filter after my observation is, invocation invoke spring container because if filter not register bean, hits once. reason , how can fix it? as have observed, spring boot automatically register bean filter servlet container. 1 option not expose filter bean , register spring security. if want able autowire dependencies filter needs bean. means need tell spring boot not register filte...