1 spring bean 生命周期
2 spring mvc 工作流程
3 spirng spring mvc spirng boot 有哪些注解
Spring
1.声明bean的注解
@Component 组件,没有明确的角色
@Service 在业务逻辑层使用(service层)
@Repository 在数据访问层使用(dao层)
@Controller 在展现层使用,控制器的声明(C)
2.注入bean的注解
@Autowired:由Spring提供
@Inject:由JSR-330提供
@Resource:由JSR-250提供
@Value 为属性注入值
@PropertySource 加载配置文件
@Profile
@Async
@Aspect
@PostConstruct 由JSR-250提供,在构造函数执行完之后执行
@Enable* 用来开启对xxx的支持。
Spring mvc
@ControllerAdvice
@ExceptionHandler
@EnableWebMvc
@RequestMapping
@RequestBody
@RestController
@PathVariable
@ModelAttribute
Spring Boot
@SpringBootApplication:包含了@ComponentScan、@Configuration和@EnableAutoConfiguration注解
@ConditionalOnMissingBean 合 @Conditional 注解,和 @ConditionalOnBean 注解相反,当容器中没有指定的 Bean 才开启配置。
4 Spring中Filter和Interceptor的区别
5 Autowired和Resource注解的区别
一、@Autowired和@Resource都可以用来装配bean,都可以写在字段上,或者方法上。
二、@Autowired属于Spring的;@Resource为JSR-250标准的注释,属于J2EE的。
三、@Autowired默认按类型装配,默认情况下必须要求依赖对象必须存在,如果要允许null值,可以设置它的required属性为false,例如:@Autowired(required=false) 如果我们想使用名称装配可以结合@Qualifier注解进行使用
@Resource,默认安装名称进行装配,名称可以通过name属性进行指定,如果没有指定name属性,当注解写在字段上时,默认取字段名进行安装名称查找