java框架之springboot框架

237 阅读1分钟

1、springboot注解

@SpringBootApplication:包含了@ComponentScan、@Configuration和@EnableAutoConfiguration注解。其中@ComponentScan让spring Boot扫描到Configuration类并把它加入到程序上下文。

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

@EnableAutoConfiguration 自动配置。

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

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

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

@Autowired自动导入。

@PathVariable获取参数。

@JsonBackReference解决嵌套外链问题。

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

2、springboot简化配置的原理

@EnableAutoConfiguration 就是 为SpringBoot实现自动配置的核心注解。它的意思就是开启自动配置功能。也就是说我们之前需要配置的东西,现在都不需要配置了 而在 @EnableAutoConfiguration 的内部又有两个非常重要的注解,分别为 @AutoConfigurationPackage 和 @Import(AutoConfigurationImportSelector.class)

3、springboot自动刷新的注解和怎样实现自动刷新