使用自定义注解实现接口参数校验
1.前言
在接口的开发中,我们有时会想让某个接口只可以被特定的人(来源)请求,那么就需要在服务端对请求参数做校验.
这种情况我们可以使用interceptor来统一进行参数校验,但是如果很多个接口,有不同的的设定值,我们总不能写很多个interceptor,然后按照path逐一添加吧?
面对这种情况,我们可以选择自定义一个注解,由注解来告诉我们,这个接口允许的访问者是谁.
mybatis源码之执行器解析
mytatis执行器主要职责是翻译jdbc操作,是mybatis非常重要的功能
执行器类图如下
-从上图中可以看出所有执行器都实现了Executor接口,定义了一些通用的操作,Executor的接口定义如下
/**
* Copyright 2009-2015 the original author or authors.
DataSourceBuilder.create().build()
Spring Boot also provides a utility builder class DataSourceBuilder that can be used to create one of the standard data sources (if it is on the classpath).