Merge pull request #26937 from quaff
* gh-26937: Polish "Update docs to use @SpringBootConfiguration not @Configuration" Update docs to use @SpringBootConfiguration not @Configuration Closes gh-26937
This commit is contained in:
commit
40a24bd537
|
@ -364,7 +364,8 @@ A single `@SpringBootApplication` annotation can be used to enable those three f
|
|||
|
||||
* `@EnableAutoConfiguration`: enable <<using-boot-auto-configuration,Spring Boot's auto-configuration mechanism>>
|
||||
* `@ComponentScan`: enable `@Component` scan on the package where the application is located (see <<using-boot-structuring-your-code,the best practices>>)
|
||||
* `@Configuration`: allow to register extra beans in the context or import additional configuration classes
|
||||
* `@SpringBootConfiguration`: enable registration of extra beans in the context or the import of additional configuration classes.
|
||||
An alternative to Spring's standard `@Configuration` that aids <<spring-boot-features#boot-features-testing-spring-boot-applications-detecting-config,configuration detection>> in your integration tests.
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
|
@ -373,7 +374,7 @@ A single `@SpringBootApplication` annotation can be used to enable those three f
|
|||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication // same as @Configuration @EnableAutoConfiguration @ComponentScan
|
||||
@SpringBootApplication // same as @SpringBootConfiguration @EnableAutoConfiguration @ComponentScan
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -395,11 +396,11 @@ For instance, you may not want to use component scan or configuration properties
|
|||
package com.example.myapplication;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.context.annotation.ComponentScan
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@SpringBootConfiguration(proxyBeanMethods = false)
|
||||
@EnableAutoConfiguration
|
||||
@Import({ MyConfig.class, MyAnotherConfig.class })
|
||||
public class Application {
|
||||
|
|
Loading…
Reference in New Issue