首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏全栈开发工程师

    Java 自定义注解简单使用

    Java 自定义注解简单使用 第一步:在 pom.xml 下引入反射框架 <dependency> <groupId>org.reflections</groupId> <artifactId >reflections</artifactId> <version>0.10.2</version> </dependency> 第二步:自定义注解 package com.zibo.api.annotation 第四步:写个工具类扫描被注解的类(核心) package com.zibo.api.utils; import com.zibo.api.annotation.MyConfig; import org.reflections.Reflections new LinkedHashMap<>(); // 要扫描的包 String packageName = "com.zibo.api.entity"; Reflections f = new Reflections(packageName); // 获取扫描到的标记注解的集合 Set<Class<?

    18210编辑于 2025-01-06
  • 来自专栏Java日常

    Java动态获取某个接口下所有的实现类对象集合

    开始想着用反射自己写一个工具类,后面懒得去折腾,就直接用第三方工具包了 , 这里我用的是org.reflections . maven配置: <dependency> <groupId>org.reflections </groupId> <artifactId>reflections-spring</artifactId> <version>${reflections.version}</version> 另外就是代码引用了,以DelayedBaseMonitor接口为例: List<DelayedBaseMonitor> monitorLists = new ArrayList<>(); Reflections reflections = new Reflections(delayedFindPackageName); Set<Class<? extends DelayedBaseMonitor>> monitorClasses = reflections.getSubTypesOf(DelayedBaseMonitor.class);

    3.1K20发布于 2020-12-24
  • 来自专栏用户1337634的专栏

    自定义枚举 --- Gson转换

    com.tenmao.utils.mybatis.converter.CodedTypeTypeAdapter; import lombok.extern.slf4j.Slf4j; import org.reflections.Reflections ; import org.reflections.scanners.SubTypesScanner; import org.springframework.http.converter.json.GsonHttpMessageConverter public HttpMessageConverter() { final GsonBuilder builder = new GsonBuilder(); final Reflections reflections = new Reflections("com.tenmao", new SubTypesScanner(true)); final Set<String> allClasses = reflections.getStore().getSubTypesOf(CodedEnum.class.getName()); for (String klass : allClasses

    1.3K21发布于 2019-03-27
  • 来自专栏物流IT圈

    java反射注解妙用-获取所有接口说明

    io.swagger.annotations.ApiOperation;import org.apache.shiro.authz.annotation.RequiresPermissions;import org.reflections.Reflections ;import org.reflections.scanners.MethodAnnotationsScanner;import org.reflections.util.ClasspathHelper ;import org.reflections.util.ConfigurationBuilder;import org.springframework.web.bind.annotation. scanPackage 需要扫描的包路径 */ private static void getRequestMappingMethod(String scanPackage) { //设置扫描路径 Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage(scanPackage

    2.1K30发布于 2019-07-16
  • 来自专栏c++与qt学习

    JAVA知识盲区整理

    工具类 依赖 <dependency> <groupId>org.reflections</groupId> <artifactId>reflections</artifactId> ; import org.reflections.Reflections; import org.reflections.scanners.*; import org.reflections.util.ClasspathHelper ; import org.reflections.util.ConfigurationBuilder; import org.reflections.util.FilterBuilder; import reflections = new Reflections( "com.mh.others.reflect_", //指定被扫描的包名 /cmj/dump/a.txt"); //将数据保存到a.txt Reflections collect = reflections.collect(new File("/home/cmj

    1.5K32发布于 2021-11-15
  • 来自专栏hml_知识记录

    Jackson父子类多态处理(注解实现)

    typeFromId:是反序列化的时候告诉序列化器怎么根据标识符来识别到具体类型,这里用了反射,在程序启动时,把要加载的包通过Reflections加载进来。 > getSubType(String type) { Reflections reflections = ReflectionsCache.getReflections(); class ReflectionsCache { private static Reflections reflections; public static void setReflections (Reflections _reflections) { reflections = _reflections; } public static Reflections reflections = new Reflections(packages); if (reflections !

    3.6K40编辑于 2022-03-24
  • 来自专栏MatheMagician

    2018 MCM Problem A notes

    (from one point on the earth’s surface to another distant point on the earth’s surface) by multiple reflections In this problem, the focus is particularly on reflections off the ocean surface. It has been found empirically that reflections off a turbulent ocean are attenuated more than reflections If additional reflections (2 through n) take place off calm oceans, what is the maximum number of hops (mss1) Part II: How do your findings from Part I compare with HF reflections off mountainous or rugged

    53330发布于 2019-09-27
  • 来自专栏JadePeng的技术博客

    来,我们一起打造一款代码命名工具

    首先添加一个辅助库: <dependency> <groupId>org.reflections</groupId> <artifactId>reflections </artifactId> <version>0.9.12</version> </dependency> 然后初始化Reflections,FilterBuilder ClasspathHelper.contextClassLoader()); classLoadersList.add(ClasspathHelper.staticClassLoader()); Reflections reflections = new Reflections(new ConfigurationBuilder() .setScanners(new SubTypesScanner extends Object>> allClasses = reflections.getSubTypesOf(Object.class); Map<String

    62510发布于 2020-09-03
  • 来自专栏明明如月的技术专栏

    巧用 Spring 自动注入实现策略模式升级版

    -- https://mvnrepository.com/artifact/org.reflections/reflections --> <dependency> <groupId>org.reflections</groupId> <artifactId>reflections</artifactId> <version >0.10.2</version> </dependency> 示例代码: import org.reflections.Reflections; import java.util.HashMap reflections = new Reflections("com.demo.xxx"); Set<Class<? >> subTypes = reflections.get(SubTypes.of(Handler.class).asClass()); for(Class<?

    2.2K20编辑于 2022-04-13
  • 来自专栏JavaGuide

    手写一个HTTP框架:两个类实现基本的IoC功能

    工具类包含3个后面会用到的方法: scanAnnotatedClass() :扫描指定包下的被指定注解标记的类(使用Reflections这个反射框架一行代码即可解决扫描获取指定注解的类)。 extends Annotation> annotation) { Reflections reflections = new Reflections(packageName, new >> annotatedClass = reflections.getTypesAnnotatedWith(annotation, true); log.info("The number > interfaceClass) { Reflections reflections = new Reflections(packageName); return reflections.getSubTypesOf

    61131发布于 2020-10-30
  • 来自专栏用户画像

    Mybatis 分页

    com.week7i.share.common.persistence.interceptor; import com.week7i.share.common.persistence.Page; import com.week7i.share.common.utils.Reflections boundSql.getParameterObject()); //解决MyBatis 分页foreach 参数失效 start if (Reflections.getFieldValue = null) { MetaObject mo = (MetaObject) Reflections.getFieldValue(boundSql, "metaParameters "); Reflections.setFieldValue(newBoundSql, "metaParameters", mo);

    1K20发布于 2019-02-22
  • 来自专栏半月无霜

    为自己模拟的IOC容器添加上DI注入

    现在,将为这个IOC容器添加DI注入功能 二、实现 在编写之前,我们先加一个工具类,用来获取接口所实现的子类Class对象,也是通过子类 <dependency> <groupId>org.reflections </groupId> <artifactId>reflections</artifactId> <version>0.10.2</version> </dependency> 代码如下, com.banmoon.test.mockioc.annotation.Bean; import com.banmoon.test.mockioc.annotation.Di; import lombok.extern.slf4j.Slf4j; import org.reflections.Reflections * 扫描的包路径 */ private String packagePath; /** * 扫描的包路径反射工具类 */ private Reflections packagePath) throws Exception { this.packagePath = packagePath; this.packageReflections = new Reflections

    41820编辑于 2023-03-07
  • 来自专栏全栈程序员必看

    mybatis清空一级缓存_jvm缓存

    -- https://mvnrepository.com/artifact/org.reflections/reflections --> <dependency> <groupId>org.reflections</groupId> <artifactId>reflections</artifactId> org.apache.ibatis.annotations.SelectProvider; import org.apache.ibatis.session.SqlSessionFactory; import org.reflections.Reflections reflections = new Reflections(STRATEGY_IMPLEMENTATION_PACKAGE); // 获取含有 CacheNamespace 注解的所有 >> classList = reflections.getTypesAnnotatedWith(CacheNamespace.class); // 遍历所有符合条件的类,进行相关业务处理

    2.1K10编辑于 2022-09-27
  • 来自专栏Linyb极客之路

    spring kafka之如何批量给topic加前缀

    AutoConfigurationPackages.get(beanFactory); for (String packageName : packageNames) { Reflections reflections = new Reflections(new ConfigurationBuilder() .forPackages(packageName addScanners(new MethodParameterScanner() ) // 添加方法参数扫描工具 ); Set<Method> methodSet = reflections.getMethodsAnnotatedWith

    81220编辑于 2022-01-06
  • 来自专栏同步文章

    【玩烂设计模式】设计模式之策略模式

    com.example.strategyTwo.annotation.Pay; import com.example.strategyTwo.service.PayStrategy; import org.reflections.Reflections static final Map<String, Class> STRATEGY_MAP = new HashMap<>(); // 获取所有支付策略 static { Reflections reflections = new Reflections(PAY_STRATEGY_IMPLEMENTATION_PACKAGE); Set<Class<? >> classSet = reflections.getTypesAnnotatedWith(Pay.class); classSet.forEach(aClass -> {

    54520编辑于 2022-10-25
  • 来自专栏Linyb极客之路

    spring kafka之如何批量给topic加前缀

    AutoConfigurationPackages.get(beanFactory); for (String packageName : packageNames) { Reflections reflections = new Reflections(new ConfigurationBuilder() .forPackages(packageName addScanners(new MethodParameterScanner() ) // 添加方法参数扫描工具 ); Set<Method> methodSet = reflections.getMethodsAnnotatedWith

    1.3K00发布于 2020-12-05
  • 来自专栏Java实战博客

    注解 & 自定义注解

    代码实现自定义注解 步骤: 使用 @Interface 定义一个注解 使用反射包 reflections 获得被标记的所有类,以及执行它们被标记的方法 <dependency> <groupId>org.reflections</groupId> <artifactId>reflections</artifactId> <version

    61310编辑于 2022-01-17
  • 来自专栏Linyb极客之路

    聊聊基于jdk实现的spi如何与spring整合实现依赖注入

    getBasePackages(importingClassMetadata); for (String basePackage : basePackages) { Reflections reflections = new Reflections(basePackage); Set<Class<? >> spiClasses = reflections.getTypesAnnotatedWith(Spi.class); if(!

    55510发布于 2021-09-02
  • 来自专栏Linyb极客之路

    聊聊基于jdk实现的spi如何与spring整合实现依赖注入

    getBasePackages(importingClassMetadata); for (String basePackage : basePackages) { Reflections reflections = new Reflections(basePackage); Set<Class<? >> spiClasses = reflections.getTypesAnnotatedWith(Spi.class); if(!

    1.5K20发布于 2021-08-17
  • 来自专栏鲸鱼动画

    CSS动画的毕业设计

    100%); border-radius: 20% 50% 50% 20%; opacity: 0.65; z-index: 0; } .ball .reflections '>

<div class='<em>reflections</em>

1.2K20发布于 2020-09-21
第 2 页第 3 页第 4 页第 5 页第 6 页第 7 页第 8 页第 9 页第 10 页第 11 页
点击加载更多
领券