美文网首页
Spring Boot 中的注解

Spring Boot 中的注解

作者: 勿以浮沙筑高台 | 来源:发表于2016-03-15 23:52 被阅读710次

@SpringBootApplication注解修饰,这包含了@ComponentSca

n、@Configuration和@EnableAutoConfiguration注解

@ComponentScan让Spring Boot扫描到Configuration类并把它加入到程序上下

文中

@Configuration 等同于spring的XML配置文件;使用java代码可以检查类型安全

@EnableAutoConfiguration 自动配置

@ComponentScan 组件扫描,可自动发现和装配一些Bean

@Component可配合CommandLineRunner使用,在程序启动后执行一些基础任务

@RestController注解是@Controller和@ResponseBody的合集,表示这是个控制器bean,并且是将函数的返回值直 接填入HTTP响应体中,是REST风格的控制器

@RequestMapping("/path")表示该控制器处理所有“/path”的UR L请求

@Autowired自动导入

@PathVariable获取参数

@JsonBackReference解决嵌套外链问题

@RepositoryRestResourcepublic配合spring-boot-starter-data-rest使用

相关文章

网友评论

      本文标题:Spring Boot 中的注解

      本文链接:https://www.haomeiwen.com/subject/xmsqlttx.html