spring boot中的注解

spring boot是个好东西,可以不用容器直接在main方法中启动,而且无需配置文件,方便快速搭建环境。

1、@RequestMapping的params参数使用场景

  当同一个类中的两个方法的功能比较相似,而且上层访问路径都是一样的情况下,就可以采用params来进去区分

    @RequestMapping(value = "/list",method=RequestMethod.GET)                 调用方式:http://xxxx/list

  @RequestMapping(value = "/list",method=RequestMethod.GET,params="method=one")    调用方式:http://xxxx/list?method=one

2、@SpringBootApplication

 很多Spring Boot开发者总是使用 @Configuration , @EnableAutoConfiguration 和 @ComponentScan 注解他们的main类。由于这些注解被如此频繁地一块使用(特别是你遵循以上最佳实践时),Spring Boot提供一个方便的 @SpringBootApplication 选择。

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

3、@RestController

该注解等价于@Controller+@ResponseBody的结合,使用这个注解的类里面的方法都以json格式输出。

原文地址:https://www.cnblogs.com/gczr/p/6689203.html