write by 张艳涛 in 202210210,after today i will  write aritles by english,because english is so diffent from chiness that i can't

understand english in java,spring doc notice ,so i begin to use english for a lifelong time. atthought  is hard for me ,but i am a man would like learn little by little , yes  is the only way to learn language by use it in common daily time

Tody I would lile recode usage of spring annotion @Aliasfor

Capture One


ToIntroduce @Aliasfor , you master kown the  @SpringBootApplication   ,it uses start Main Class, then show the context

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(excludeFilters = {
@Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
@Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
public @interface SpringBootApplication { /**
* Exclude specific auto-configuration classes such that they will never be applied.
* @return the classes to exclude
*/
@AliasFor(annotation = EnableAutoConfiguration.class)
Class<?>[] exclude() default {}; /**
* Exclude specific auto-configuration class names such that they will never be
* applied.
* @return the class names to exclude
* @since 1.3.0
*/
@AliasFor(annotation = EnableAutoConfiguration.class)
String[] excludeName() default {}; /**
* Base packages to scan for annotated components. Use {@link #scanBasePackageClasses}
* for a type-safe alternative to String-based package names.
* @return base packages to scan
* @since 1.3.0
*/
@AliasFor(annotation = ComponentScan.class, attribute = "basePackages")
String[] scanBasePackages() default {}; /**
* Type-safe alternative to {@link #scanBasePackages} for specifying the packages to
* scan for annotated components. The package of each class specified will be scanned.
* <p>
* Consider creating a special no-op marker class or interface in each package that
* serves no purpose other than being referenced by this attribute.
* @return base packages to scan
* @since 1.3.0
*/
@AliasFor(annotation = ComponentScan.class, attribute = "basePackageClasses")
Class<?>[] scanBasePackageClasses() default {}; }

and  with

@SpringBootApplication(scanBasePackages ={ "com.zyt" } )//这个是rouyi的方案
public class ZytAuthApplication {
public static void main(String[] args) {
SpringApplication.run(ZytAuthApplication.class, args);
System.out.println("(◠‿◠)ノ゙ 授权认证中心启动成功 ლ(´ڡ`ლ)゙ \n" );
}
}

you can know the attibute  (scanBasePackages ={ "com.zyt" } ) is for

    @AliasFor(annotation = ComponentScan.class, attribute = "basePackages")
String[] scanBasePackages() default {};

then the  SpringBootApplication Annotation attibute scanBasePackages ={ "com.zyt" } , so we can undestand

@AliasFor isfor give scanBasePackages ={ "com.zyt" } to ComponentScan.class ,
ComponentScan overrite its attibute  with {"com.zyt"}
In One World like  meta-annotation get attibute value from Top Annotation 's attibute
this is call Explicit alias for attribute in meta-annotation:

Capture Two


Explicit aliases within an annotation: 
 public @interface ContextConfiguration {

      @AliasFor("locations")
String[] value() default {}; @AliasFor("value")
String[] locations() default {}; // ...
}

for more

Capture Three



Example: Implicit Aliases within an Annotation
 @ContextConfiguration
public @interface MyTestConfig { @AliasFor(annotation = ContextConfiguration.class, attribute = "locations")
String[] value() default {}; @AliasFor(annotation = ContextConfiguration.class, attribute = "locations")
String[] groovyScripts() default {}; @AliasFor(annotation = ContextConfiguration.class, attribute = "locations")
String[] xmlFiles() default {};
}
 @MyTestConfig
public @interface GroovyOrXmlTestConfig { @AliasFor(annotation = MyTestConfig.class, attribute = "groovyScripts")
String[] groovy() default {}; @AliasFor(annotation = ContextConfiguration.class, attribute = "locations")
String[] xml() default {};
}

for more

构建后端第3篇之---springb @Alias注解使用的更多相关文章

  1. 构建后端第2篇之---springb @ComponentScan注解使用

    张艳涛写于2021-2-8日 构建后端项目的时候遇到一个问题,在zyt-auth项目的依赖定义了@Component类,这个类在项目启动的时候提示没有找到bean Field tokenService ...

  2. 构建后端第6篇之---java 多态的本质 父类引用 指向子类实现

    张艳涛写于2021-2-20 今天来个破例了,不用英文写了,今天在家里电脑写的工具不行,简单的说 主题是:java多态的原理与实现 结论是:java的多态 Father father= new Son ...

  3. 构建后端第5篇之---Idea 查看继承 实现关系图

    first question: how to show a class  children class :  move mousrmark to class name , Ctrl + H how t ...

  4. 构建后端第4篇之---spring 源码阅读构建环境

    解决 IDEA 创建 Gradle 项目没有src目录问题 in new model named zyt-study   root dir there are  a build.gradle plug ...

  5. 构建后端第1篇之---springcloud项目依赖分析

    张艳涛写于2021-2-2日 springcloud是springboot工程+cloud依赖,从这个角度来分析,使用springcloud实际上就是添加springcloud的某个以来比如eurek ...

  6. JSON工具类的构建(后端版本)

    前言 在前后端交互的选择上,之前一直采用的是模板引擎(因为我只负责后端). 而这次的一个算是作业吧,前后端都是我,所以就研究了一下JSON交互在java web的应用(主要是前端). 优缺点 前后端耦 ...

  7. 高效使用Java构建工具,Maven篇|云效工程师指北

    大家好,我是胡晓宇,目前在云效主要负责Flow流水线编排.任务调度与执行引擎相关的工作. 作为一个有多年Java开发测试工具链开发经验的CRUD专家,使用过所有主流的Java构建工具,对于如何高效使用 ...

  8. NodeJS+Express下构建后端MVC文件结构

    关于MVC的结构大体上有两种方式,其一按照层级进行文件夹分类,其二是按照业务进行文件夹分类.关于这个demo相关的业务简单,所以暂采用第一种的方式,当然实际当中很恨复杂的项目可以采用两种方式相结合的方 ...

  9. gulp前端自动化构建工具新手入门篇

    很久没有更新博文了. 经过了一次年前吐血的赶项目,终于在年后回血了.趁着有空,新学到了一个前端自动化构建工具-gulp. 现在我们通过这3个问题来学习一下: 1.什么是gulp? 2.为什么要用gul ...

随机推荐

  1. WPF Frame 的 DataContext 不能被 Page 继承

    转载至https://blog.csdn.net/sinat_31608641/article/details/88914517 已测试解决方案可行,因为WPF相关资料稀少,防止日后404,特搬运到自 ...

  2. 深入理解 sync.Once 与 sync.Pool

    深入理解 sync.Once 与 sync.Pool sync.Once 代表在这个对象下在这个示例下多次执行能保证只会执行一次操作. var once sync.Once for i:=0; i & ...

  3. VLAN协议与三层交换机 (Access/Trubk/Hrbrid)

    VLAN协议与三层交换机(Access/Trunk/Hybrid) 目录 一.VLAN概述 1.1.分割广播域 1.2.VLAN的优势 1.3.静态VLAN 二.Trunk的作用 2.1.概念 2.2 ...

  4. 20204107 孙嘉临 《PYTHON程序设计》实验四报告

    课程:<Python程序设计>班级: 2041姓名: 孙嘉临学号: 20204107实验教师:王志强实验日期:2020年6月29日必修/选修: 公选课 ##作为一个轻度游戏玩家,当然是要写 ...

  5. 铂金07:整齐划一-CountDownLatch如何协调多线程的开始和结束

    欢迎来到<并发王者课>,本文是该系列文章中的第20篇. 在上一篇文章中,我们介绍了Condition的用法.在本文中,将为你介绍CountDownLatch的用法.CountDownLat ...

  6. 什么是DDoS引导程序IP Stresser?

    1.什么是IP Stresser? IP Stresser是一款用于测试网络或服务器稳健性的工具.管理员可以运行压力测试,从而确定现有资源(带宽.CPU 等)是否足以处理附加负载. 测试个人网络或服务 ...

  7. Mongo3基础操作

    由于3.X的文档是在3.X当前最新版本前记录,所以这里列出一些常用的操作,比如建立库,删除库,等一些格式,然后在描述开启远程和创建用户的一些区别,以及讲解2.X和3.X配置文件区别. 1. Mongo ...

  8. layui laydate 设置日期格式 最大值等

    laydate.render({ elem: "#jhsj", format: 'yyyy-MM', type: 'month', //显示月份 year 显示到年 max : & ...

  9. Java的类加载器种类

    Java类加载器采用双亲委派模型: 1.启动类加载器:这个类加载器负责放在<JAVA_HOME>\lib目录中的,或者被-Xbootclasspath参数所指定的路径中的,并且是虚拟机识别 ...

  10. linux学习之路第三天

    开机,重启和用户登陆注销 关机&重启命令 shutdown shutdown -h now :表示立即关机 shutdown -h 1 :表示一分钟后关机 shutdown -r now :表 ...