当前位置:网站首页>注解用法含义
注解用法含义
2022-07-31 03:00:00 【杰拉德·皮克·谢】
根据层次来解释说明前后端分离
后端
XXApplication层
- @SpringBootApplication SpringBoot程序入口
// 注解后加括号字段为扫描指定的包
@SpringBootApplication(scanBasePackages = "com.zaofeng.good")
@EnableEurekaClient // 服务提供者
@EnableDiscoveryClient // 服务消费者
@EnableEurekaClient,@EnableDiscoveryClient两者区别
- @EnableFeignClients // 启用feign客户端
- @MapperScan(basePackages = {“com.zaofeng.good.common.mapper”, “com.zaofeng.good.service.digiccy.mapper” }) // 作用:指定要变成实现类的接口所在的包,然后包下面的所有接口在编译之后都会生成相应的实现类。添加位置:是在Springboot启动类上面添加
- @EnableSwagger2 //表示开启 Swagger
Mapper(DAO)层
- @Repository // Spring 自 2.0 版本开始,陆续引入了一些注解用于简化 Spring 的开发。@Repository注解便属于最先引入的一批,它用于将数据访问层 (DAO 层 ) 的类标识为 Spring Bean。具体只需将该注解标注在 DAO类上即可。同时,为了让 Spring 能够扫描类路径中的类并识别出 @Repository 注解,需要在 XML 配置文件中启用Bean 的自动扫描功能,这可以通过context:component-scan/实现。
- @CacheNamespace// 开启二级缓存
@CacheNamespace(implementation = RedisCache.class)
Service(层)
impl
@Service
@Service解释@Autowired // 建立连接 Servic 和 Dao(浅显理解)
@Autowired解释@Override // 重写方法
@Overrid详解@Transactional
@Transactional(readOnly = true) // 只读
Controller(层)
@Controller
@RestController
@Controller和@RestController的区别@Autowired // 通常是和Service产生关系
@RequestMapping
@RequestMapping详解@ApiOperation(value = “交易所列表”)。。。 // 文档注解
@ApiOperation(value = "交易所列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "int", paramType = "path"),
@ApiImplicitParam(name = "pageSize", value = "笔数", required = true, dataType = "int", paramType = "path"),
@ApiImplicitParam(name = "tbDigiccyExchangeJson", value = "对象 JSON 格式", required = false, dataTypeClass = String.class, paramType = "json")
})
前
边栏推荐
- Uninstallation of mysql5.7.37 under CentOS7 [perfect solution]
- QML的使用
- LeetCode Daily Question 2022/7/25-2022/7/31
- 4、敏感词过滤(前缀树)
- Mathematical Ideas in AI
- The application of AI in the whole process of medical imaging equipment
- SQL injection Less47 (error injection) and Less49 (time blind injection)
- Installation of mysql5.7.37 under CentOS7 [perfect solution]
- Multilingual settings of php website (IP address distinguishes domestic and foreign)
- 【HCIP】ISIS
猜你喜欢
随机推荐
BAT can't sell "Medical Cloud": Hospitals flee, mountains stand, and there are rules
Unity3D Button mouse hover enter and mouse hover exit button events
Huawei od dice js
YOLOV5学习笔记(二)——环境安装+运行+训练
Intel's software and hardware optimization empowers Neusoft to accelerate the arrival of the era of smart medical care
【编译原理】递归下降语法分析设计原理与实现
[Android] Room - Alternative to SQLite
【编译原理】词法分析程序设计原理与实现
接口测试关键技术
STM32问题合集
The application of AI in the whole process of medical imaging equipment
刚出道“一战成名”,安全、舒适一个不落
11. Redis implements follow, unfollow, and follow and follower lists
字体压缩神器font-spider的使用
CorelDRAW2022精简亚太新增功能详细介绍
如何搭建私有yum源
[Godot][GDScript] 二维洞穴地图随机生成
php 网站的多语言设置(IP地址区分国内国外)
Mathematical Ideas in AI
CefSharp入门-winform