By default Spring Boot creates a FilterRegistrationBean
for every Filter
in the application context for which a FilterRegistrationBean
doesn’t already exist. This allows you to take control of the registration process, including disabling registration, by declaring your own FilterRegistrationBean
for the Filter
. For your PreAuthenticationFilter
the required configuration would look like this:
@Bean
public FilterRegistrationBean registration(PreAuthenticationFilter filter) {
FilterRegistrationBean registration = new FilterRegistrationBean(filter);
registration.setEnabled(false);
return registration;
}
You may also be interested in this Spring Boot issue which discusses how to disable the automatic registration of Filter
and Servlet
beans.