SpringBoot注解

一、声明bean注解

1@Component通用注解2@Controller表现层3@Service业务逻辑层4@Repository数据访问层(dao层)5@RestController表现层,@Controller+@ResponseBody


二、注入bean注解

1@Resource
2@Autowiredspring提供3@Inject


三、bean作用域、bean生命周期注解

1、bean的作用域

1@Scope


1) singleton :单例,spring默认配置,一个spring容器中只有一个bean的实例,全容器共享一个实例。

2) Prototpe :多实例,每次调用创建一个bean实例

3) Request :

4) Session :

5) GlobalSession :


2、bean的生命周期

1

2



四、main方法入口注解

1@SpringBootApplication


1

2

3


五、aop注解

1

2

3

4












一、Controller层

1@SpringBoorApplicationspringboot启动注解2@configurationspringboot3@EnableAutoConfiguration
4@RestControllercontroller层注解,相当于@ResponseBody和@Controller的组合注解5@Controllercontroller层注解6@ResponseBody返回json格式,与@Controller搭配使用7@RequestMapping请求路径限制8@RequestParam读取请求参数9



二、Service层1@Serviceservice层注解2@Autowired自动装配3@Resource注入对象之间的关系4@Value



三、持久层

@Mapper
@Repository

1@MapperDao层注解2@Query
3@Param
4



四、表的映射1@Entity实体类注解2@Table表名3@Id表中的id4@Transient