SpringBootApplication

来源:互联网 发布:淘宝商盟是什么 编辑:程序博客网 时间:2024/05/16 12:22


http://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-using-springbootapplication-annotation.html


18. Using the @SpringBootApplication annotation

Many Spring Boot developers always have their main class annotated with @Configuration, @EnableAutoConfiguration and @ComponentScan. Since these annotations are so frequently used together (especially if you follow thebest practices above), Spring Boot provides a convenient@SpringBootApplication alternative.

The @SpringBootApplication annotation is equivalent to using@Configuration, @EnableAutoConfiguration and@ComponentScan with their default attributes:

package com.example.myproject;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication // same as @Configuration @EnableAutoConfiguration @ComponentScanpublic class Application {    public static void main(String[] args) {        SpringApplication.run(Application.class, args);    }}
原创粉丝点击