Skip to content

Commit e5e497e

Browse files
committed
Document @ImportAutoConfiguration#exclude
Closes gh-7862
1 parent e44b595 commit e5e497e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfiguration.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,9 @@
3131
* rules as {@code @EnableAutoConfiguration} but restricts the auto-configuration classes
3232
* to the specified set, rather than consulting {@code spring.factories}.
3333
* <p>
34+
* Can also be used to {@link #exclude()} specific auto-configuration classes such that
35+
* they will never be applied.
36+
* <p>
3437
* Generally, {@code @EnableAutoConfiguration} should be used in preference to this
3538
* annotation, however, {@code @ImportAutoConfiguration} can be useful in some situations
3639
* and especially when writing tests.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5383,6 +5383,10 @@ providing a `@...Test` annotation that loads the `ApplicationContext` and one or
53835383
more `@AutoConfigure...` annotations that can be used to customize auto-configuration
53845384
settings.
53855385

5386+
NOTE: Each slice loads a very restricted set of auto-configuration classes. If you need to
5387+
exclude one of them, most `@...Test` annotation provide an `excludeAutoConfiguration`
5388+
attribute. Alternatively, you can use `@ImportAutoConfiguration#exclude`.
5389+
53865390
TIP: It's also possible to use the `@AutoConfigure...` annotations with the standard
53875391
`@SpringBootTest` annotation. You can use this combination if you're not interested
53885392
in '`slicing`' your application but you want some of the auto-configured test beans.

0 commit comments

Comments
 (0)