Skip to content

Commit 0ef3de4

Browse files
committed
Document how to disable auto registration of a Servlet or Filter bean
Closes gh-2173
1 parent b183309 commit 0ef3de4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

spring-boot-docs/src/main/asciidoc/howto.adoc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,25 @@ the underlying component.
335335

336336

337337

338+
[[howto-disable-registration-of-a-servlet-or-filter]]
339+
=== Disable registration of a Servlet or Filter
340+
As <<howto-add-a-servlet-filter-or-servletcontextlistener,described above>> any `Servlet`
341+
or `Filter` beans will be registered with the servlet container automatically. To disable
342+
registration of a particular `Filter` or `Servlet` bean create a registration bean for it
343+
and mark it as disabled. For example:
344+
345+
[source,java,indent=0,subs="verbatim,quotes,attributes"]
346+
----
347+
Bean
348+
public FilterRegistrationBean registration(MyFilter filter) {
349+
FilterRegistrationBean registration = new FilterRegistrationBean(filter);
350+
registration.setEnabled(false);
351+
return registration;
352+
}
353+
----
354+
355+
356+
338357
[[howto-change-the-http-port]]
339358
=== Change the HTTP port
340359
In a standalone application the main HTTP port defaults to `8080`, but can be set with

0 commit comments

Comments
 (0)