@RequestMapping和@GetMapping区别;springboot中@SpringBootApplication 是什么意思呢?

区别:
功能是一样的,书写格式不同,在Spring4.3版本以后,提供了@GetMapping注解更方便了开发:

/**
 * @auther SyntacticSugar
 * @data 2018/11/1 0001下午 7:02
 */
@RestController
@RequestMapping
public class HelloController {
    //@RequestMapping(value = "hello", method= RequestMethod.GET )
    @GetMapping("hello")
    public String hello() {
       return "hello spring boot";
    }
}

参看源码:
@RequestMapping和@GetMapping区别;springboot中@SpringBootApplication 是什么意思呢?

springboot快速搭建springMVC:
步骤:①maven的 pom.xml中引用springboot父工程,②启用web-starter③写main函数;

    <!-- 父工程 -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.RELEASE</version>
    </parent>
    <!-- 引入 starter-web -->
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

写 main 函数:

/**
 * @auther SyntacticSugar
 * @data 2018/11/1 0001下午 6:56
 */
@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class,args);
    }
}

controller上面有:跑一下,有效果;
@RequestMapping和@GetMapping区别;springboot中@SpringBootApplication 是什么意思呢?
@RequestMapping和@GetMapping区别;springboot中@SpringBootApplication 是什么意思呢?
我们经常写的@SpringBootApplication 是什么意思呢?
@SpringBootApplication 源码点开瞟一眼:

@RequestMapping和@GetMapping区别;springboot中@SpringBootApplication 是什么意思呢?

*我们发现@SpringBootApplication 中包含 @link Configuration、@link EnableAutoConfiguration、@link ComponentScan ,这一个注解代替了这三个注解; *

(1)@Configuration 和 @bean 注入定义了一个实体类;
(2)@EnableAutoConfiguration 启用了上下文自动配置;
(3)@ComponentScan 扫描指定的包,若未指定值,默认扫包范围:被注释的 class所在的包;