构建后端第3篇之---springb @Alias注解使用
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注解使用的更多相关文章
- 构建后端第2篇之---springb @ComponentScan注解使用
张艳涛写于2021-2-8日 构建后端项目的时候遇到一个问题,在zyt-auth项目的依赖定义了@Component类,这个类在项目启动的时候提示没有找到bean Field tokenService ...
- 构建后端第6篇之---java 多态的本质 父类引用 指向子类实现
张艳涛写于2021-2-20 今天来个破例了,不用英文写了,今天在家里电脑写的工具不行,简单的说 主题是:java多态的原理与实现 结论是:java的多态 Father father= new Son ...
- 构建后端第5篇之---Idea 查看继承 实现关系图
first question: how to show a class children class : move mousrmark to class name , Ctrl + H how t ...
- 构建后端第4篇之---spring 源码阅读构建环境
解决 IDEA 创建 Gradle 项目没有src目录问题 in new model named zyt-study root dir there are a build.gradle plug ...
- 构建后端第1篇之---springcloud项目依赖分析
张艳涛写于2021-2-2日 springcloud是springboot工程+cloud依赖,从这个角度来分析,使用springcloud实际上就是添加springcloud的某个以来比如eurek ...
- JSON工具类的构建(后端版本)
前言 在前后端交互的选择上,之前一直采用的是模板引擎(因为我只负责后端). 而这次的一个算是作业吧,前后端都是我,所以就研究了一下JSON交互在java web的应用(主要是前端). 优缺点 前后端耦 ...
- 高效使用Java构建工具,Maven篇|云效工程师指北
大家好,我是胡晓宇,目前在云效主要负责Flow流水线编排.任务调度与执行引擎相关的工作. 作为一个有多年Java开发测试工具链开发经验的CRUD专家,使用过所有主流的Java构建工具,对于如何高效使用 ...
- NodeJS+Express下构建后端MVC文件结构
关于MVC的结构大体上有两种方式,其一按照层级进行文件夹分类,其二是按照业务进行文件夹分类.关于这个demo相关的业务简单,所以暂采用第一种的方式,当然实际当中很恨复杂的项目可以采用两种方式相结合的方 ...
- gulp前端自动化构建工具新手入门篇
很久没有更新博文了. 经过了一次年前吐血的赶项目,终于在年后回血了.趁着有空,新学到了一个前端自动化构建工具-gulp. 现在我们通过这3个问题来学习一下: 1.什么是gulp? 2.为什么要用gul ...
随机推荐
- Spring Boot WebFlux-09——WebFlux 集成测试及部署
第09课:WebFlux 集成测试及部署 前言 在日常工作中,免不了自测 UT,因为覆盖率不达标,是不允许提交测试,那怎么进行 WebFlux 项目的测试呢.@WebFluxTest 是 WebFlu ...
- Spring Boot WebFlux-02——WebFlux Web CRUD 实践
第02课:WebFlux Web CRUD 实践 上一篇基于功能性端点去创建一个简单服务,实现了 Hello.这一篇用 Spring Boot WebFlux 的注解控制层技术创建一个 CRUD We ...
- 「10.13」毛一琛(meet in the middle)·毛二琛(DP)·毛三琛(二分+随机化???)
A. 毛一琛 考虑到直接枚举的话时间复杂度很高,我们运用$meet\ in\ the\ middle$的思想 一般这种思想看似主要用在搜索这类算法中 发现直接枚举时间复杂度过高考虑枚举一半另一半通过其 ...
- Linux关闭打开防火墙命令
Linux下打开和关闭防火墙 1.及时生效,重启后复原 关闭:service iptables stop 开启:service iptalbes start 查看状态:service iptabl ...
- Activity侧滑返回的实现原理
简介 使用侧滑Activity返回很常见,例如微信就用到了.那么它是怎么实现的呢.本文带你剖析一下实现原理.我在github上找了一个star有2.6k的开源,我们分析他是怎么实现的 //star 2 ...
- js判断字符串为空或者为null 简写
if (str1!== null || str1!== undefined || str1!== '') { var str2= str1; } 下面是简写 var str2= str1|| ''; ...
- 我用段子讲.NET之依赖注入其一
<我用段子讲.NET之依赖注入其一> 1) 西城的某个人工湖畔,湖水清澈见底,湖畔柳树成荫.人工湖往北,坐落着两幢写字楼,水晶大厦靠近地铁站,由于为了与湖面天际线保持一致,楼层只有26层高 ...
- 技术如何转产品01——1+1>2?
当业务复杂到一定阶段的时候,效率问题会首当其冲,基本解法是化整为零.分赛道,对应的产物可以是子公司>>事业部>业务单元>项目组. 好处是目标聚焦.所以问题也会聚焦,工作内容闭 ...
- 『心善渊』Selenium3.0基础 — 15、Selenium对多窗口的操作
目录 1.多标签/多窗口之间的切换 2.句柄练习 1.多标签/多窗口之间的切换 (1)多标签/多窗口场景: 在页面操作过程中有时候点击某个链接会弹出新的窗口,这时就需要切换到新打开的窗口上进行操作,如 ...
- NoSql非关系型数据库之MongoDB应用(二):安装MongoDB可视化工具
业精于勤,荒于嬉:行成于思,毁于随. 我们上次说到NoSql非关系型数据库之MongoDB应用(一):安装MongoDB服务 这次我们介绍安装 NoSQL Manager for MongoDB 可 ...