> For the complete documentation index, see [llms.txt](https://jack80342.gitbook.io/spring-boot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jack80342.gitbook.io/spring-boot/iii.-using-spring-boot/18.-using-the-springbootapplication-annotation.md).

# 18. 使用@SpringBootApplication注解

很多Spring Boot开发者经常使用`@Configuration`，`@EnableAutoConfiguration`，`@ComponentScan`注解他们的main类，由于这些注解如此频繁地一块使用（特别是遵循以上[最佳实践](https://github.com/jack80342/spring-boot/tree/25350df33f8edd68b50ff6f6e1258c9df4f67d67/III.%20Using%20Spring%20Boot/14.%20Structuring%20your%20code.md)的时候），Spring Boot就提供了一个方便的`@SpringBootApplication`注解作为代替。

`@SpringBootApplication`注解等价于以默认属性使用`@Configuration`，`@EnableAutoConfiguration`和`@ComponentScan`：

```java
package com.example.myapplication;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication // same as @Configuration @EnableAutoConfiguration @ComponentScan
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}
```

**注** `@SpringBootApplication`注解也提供了用于自定义`@EnableAutoConfiguration`和`@ComponentScan`属性的别名（aliases）。
