构建后端第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 ...
随机推荐
- MySQL零散知识点(01)
内容概要 --- 表字段操作补充(掌握) --- python操作MySQL(掌握) --- 视图(了解) --- 触发器(了解) --- 存储过程(了解) --- 事务(掌握) --- 内置函数(了 ...
- noip模拟8[星际旅行·砍树·超级树·求和]
也不能算考得好,虽然这次A了一道题,但主要是那道题太简单了,没啥成就感,而且有好多人都A掉了 除了那一道,其他的加起来一共拿了25pts,这我能咋办,无奈的去改题 整场考试的状态并不是很好啊,不知道是 ...
- 会点自动化就要25k? 现在年轻人这么浮躁吗
面试中一问元素定位就对答如流.一问实际项目框架如何搭建就避重就轻.含糊其辞,这样的自动化实战能力也能拿25K?静待下文: 一.为什么现在自动化测试工资那么高呢? 结合现在的职场环境与企业用人需求,自动 ...
- Centos8.3、proxysql2.0读写分离实战记录
接着主从复制继续往下讲,这个项目中我是使用proxysql做读写分离的中间件,之前是使用mycat.老实说mycat属于比较重量级的中间件,1.0还好到了2.0配置变得很复杂而且文档不是很齐全,我看着 ...
- Hadoop - 彻底解决警告:WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform...
目录 1 - 在日志配置文件中忽略警告 - 有效 2 - 指定本地库的路径 - 无效 3 - 不使用 Hadoop 本地库 - 无效 4 - 替换 Hadoop 本地库 - 有效 5 - 根据源码,编 ...
- thinkphp5.0 QQ第三方登录详解
一.前期准备工作 到QQ互联官网进行开发资质认证,并创建网站应用.获取到appid和appkey后,下载demo文件. demo文件下载方式:QQ互联>文档资料>SDK及资源下载>p ...
- POJ 1015 Jury Compromise dp
大致题意: 从n个候选人中选出m个人作为陪审团.为了让陪审团的选择更公平,辩方和控方都为这n个候选人给出了满意度(辩方为D[j],控方为P[j],范围0至20).现在要使得选出的m位候选人的辩方总和与 ...
- Python迭代器和生成器你学会了吗?
在了解什么是迭代器和生成器之前,我们先来了解一下容器的概念.对于一切皆对象来说,容器就是对象的集合.例如列表.元祖.字典等等都是容器.对于容器,你可以很直观地想象成多个元素在一起的单元:而不同容器的区 ...
- CentOS-Docker搭建Nacos-v1.1.4(单点)
通用属性配置(v1.1.4) name description option MODE cluster模式/standalone模式 cluster/standalone default cluste ...
- MySql:使用Navicat定时备份数据库
Navicat自带就有备份 还可以直接计划任务,很方便. 1. 新建计划 打开navicat客户端,连上mysql后,双击左边你想要备份的数据库.点击"计划",再点击" ...