springboot三层架构及常用注解

一、entiy 实体类,各种实体类型 常用注解 @Data 相当于get,set,tostring @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) 链式写代码 @TableName(“数据库表”) 绑定数据库表 @TableField(“数据库中的名字”) 二、controller 控制层 @requestMapping()url路径 @Controller 跳页面 @ResponseBody 返回数据 @RestController = @Controller + @ResponseBody @Slf4j 开启日志注解 三、service 连接dao层进行操作,通常加@service注解 @service 注解用到serviceImpl层,使用之后可使用@Autowired,不会出现NullPoint异常 通常继承IService(相应的dao层,实体类)

四、dao 连接数据库层,写增删改查的一些方法,通常继承BaseMapper(实体类)

五、springboot启动类 @SpringBootApplication @EnableTransactionManagement //事务注解 @MapperScan(“dao层路径”) public class WhZwfwApplication {

} @SpringBootApplication = @Configuration+@EnableAutoConfiguration+@ComponentScan

经验分享 程序员 微信小程序 职场和发展