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

最新文章

  1. Curling 2.0
  2. Tomcat中取消断点
  3. 本地wampserver如何配置伪静态
  4. 【OOAD】OOP的主要特征
  5. 尝试制作了一个Panorama
  6. display:-webkit-box
  7. jQuery_效果(隐藏和显示)
  8. 《零成本实现Web自动化测试--基于Selenium》第二章 Selenium简介和基础
  9. C++类的大小
  10. 工欲善其事必先利其器-Notepad++使用小记(Python)
  11. iOS 开发者旅途中的指南针 - LLDB 调试技术
  12. C# Main函数详解
  13. sublime 安装package control
  14. Oracle Advanced Pricing White Papers
  15. (1)编译安装lamp三部曲之apache-技术流ken
  16. 自己动手写处理器之第二阶段(1)——可编程逻辑器件与PLD电路设计流程
  17. [Docker]Docker拉取,上传镜像到Harbor仓库
  18. django-内网项目上线测试部署步骤
  19. 不固定个数组,进行一一对应的组合,js将多个数组实现排列组合
  20. 笔记二:常用的h5语义化标签

热门文章

  1. Django基础之自定义分页器
  2. 网络游戏逆向分析-3-通过发包函数找功能call
  3. java线程和操作系统线程的异同(大图对比)
  4. huge page 能给MySQL 带来性能提升吗?
  5. 代码实测:给redis中的key取一个正确的名字多么重要
  6. docker 自定义部署Springboot——依赖与代码分离部署
  7. ABP Framework:移除 EF Core Migrations 项目,统一数据上下文
  8. 4.13、nfs挂载优化及优缺点
  9. POJ 2002 二分 计算几何
  10. Basic remains java入门题