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. Kubernetes集群安装

    一.环境介绍 主机名 IP地址 master 192.168.0.100 node1 192.168.0.101 node2 192.168.0.102 1.1.操作系统: CensOS8.4.210 ...

  2. STP协议与MSTP协议

    STP协议与MSTP协议 目录 一.STP概述 1.1.交换网络环路的产生 1.2.STP简介 二.生成树算法 2.1.生成树算法的步骤 2.2.网桥 ID 2.3.选择根端口 2.4.选择指定端口 ...

  3. Golang去除字符串前后空格

    Golang去除字符串前后空格 实现Demo package main import "fmt" func DeletePreAndSufSpace(str string) str ...

  4. 简易版JDBC连接池

    JDBC连接池mini版的实现 首先是工具类 DbUtil 主要参数就是Driver.User.PWD等啦,主要用于建立连接 URL需要注意的是SSL和serverTimezone参数,和mysql驱 ...

  5. 9.4、安装zabbix(1)

    1.什么是zabbix: zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案: zabbix能监视各种网络参数,保证服务器系统的安全运营:并提供灵活的通知机制以 ...

  6. hdu 3306 Another kind of Fibonacci 矩阵快速幂

    参考了某大佬的 我们可以根据(s[n-2], a[n-1]^2, a[n-1]*a[n-2], a[n-2]^2) * A = (s[n-1], a[n]^2, a[n]*a[n-1], a[n-1] ...

  7. 如何筛选CRM客户系统无效数据

    企业将各个渠道获得的大量数据导入CRM系统之后,要如何筛选CRM客户系统无效数据?销售人员应该将更多的时间用于发掘潜在客户,而不是浪费时间来检索CRM数据.Zoho CRM能够呈现最有价值的客户,让销 ...

  8. Spring中这么重要的AnnotationAwareAspectJAutoProxyCreator类是干嘛的?

    大家好,我是冰河~~ 停更了很久的[Spring注解系列]专题,终于重新更新了,我们还是接着之前的文章继续往下更新.在<[Spring注解驱动开发]二狗子让我给他讲讲@EnableAspectJ ...

  9. CentOS7-磁盘扩容(LVM-非空目录拓展卷空间大小)

    查看存储情况 $ df -kh 查看磁盘情况 $ fdisk -l 创建分区(注:可操作存储上限2TB) $ fdisk /dev/sdb 根据提示,依次输入"n","p ...

  10. 暑假自学java第三天

    1,java中有个c++中没有的数据类型 bite:byte的取值范围为-128~127,占用1个字节(-2的7次方到2的7次方-1) 在通常情况下,如果JAVA中出现了一个整数数字比如35,那么这个 ...