diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfiguration.java index ce214673c2..af55f05b8d 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,9 @@ import org.springframework.core.annotation.AliasFor; * rules as {@code @EnableAutoConfiguration} but restricts the auto-configuration classes * to the specified set, rather than consulting {@code spring.factories}. *

+ * Can also be used to {@link #exclude()} specific auto-configuration classes such that + * they will never be applied. + *

* Generally, {@code @EnableAutoConfiguration} should be used in preference to this * annotation, however, {@code @ImportAutoConfiguration} can be useful in some situations * and especially when writing tests. diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index c9b13d71da..80825fcf9a 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -5344,6 +5344,10 @@ providing a `@...Test` annotation that loads the `ApplicationContext` and one or more `@AutoConfigure...` annotations that can be used to customize auto-configuration settings. +NOTE: Each slice loads a very restricted set of auto-configuration classes. If you need to +exclude one of them, most `@...Test` annotation provide an `excludeAutoConfiguration` +attribute. Alternatively, you can use `@ImportAutoConfiguration#exclude`. + TIP: It's also possible to use the `@AutoConfigure...` annotations with the standard `@SpringBootTest` annotation. You can use this combination if you're not interested in '`slicing`' your application but you want some of the auto-configured test beans.