Skip to content

Commit c816b00

Browse files
committed
Merge pull request #19855 from protyay
* pr/19855: Polish "Encourage use of SpringBootApplication" Encourage use of SpringBootApplication Closes gh-19855
2 parents 8dc3e74 + 650e55c commit c816b00

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

spring-boot-project/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -397,21 +397,20 @@ Doing so enables debug logs for a selection of core loggers and logs a condition
397397

398398
[[using-boot-disabling-specific-auto-configuration]]
399399
=== Disabling Specific Auto-configuration Classes
400-
If you find that specific auto-configuration classes that you do not want are being applied, you can use the exclude attribute of `@EnableAutoConfiguration` to disable them, as shown in the following example:
400+
If you find that specific auto-configuration classes that you do not want are being applied, you can use the exclude attribute of `@SpringBootApplication` to disable them, as shown in the following example:
401401

402402
[source,java,indent=0]
403403
----
404404
import org.springframework.boot.autoconfigure.*;
405405
import org.springframework.boot.autoconfigure.jdbc.*;
406-
import org.springframework.context.annotation.*;
407406
408-
@Configuration
409-
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
410-
public class MyConfiguration {
407+
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})
408+
public class MyApplication {
411409
}
412410
----
413411

414412
If the class is not on the classpath, you can use the `excludeName` attribute of the annotation and specify the fully qualified name instead.
413+
If you prefer to use `@EnableAutoConfiguration` rather than `@SpringBootApplication`, `exclude` and `excludeName` are also available.
415414
Finally, you can also control the list of auto-configuration classes to exclude by using the `spring.autoconfigure.exclude` property.
416415

417416
TIP: You can define exclusions both at the annotation level and by using the property.

0 commit comments

Comments
 (0)