当前位置: 首页 > news >正文

学做点心上哪个网站成人教育培训机构排名

学做点心上哪个网站,成人教育培训机构排名,wordpress 评论函数,wordpress文章前添加图标背景 : 需求 需要获取某个包下的所有的注解 并不是全部项目的 所以 只用针对某个包 进行扫描 获取注解 数据就行 百度了一圈 spring boot 没有自带的 获取注解集合的方法 在看 php 中 hyperf 框架 看到了 这个方法 就是因为 我需求是 php 和java 合体 微服务开发 …

背景 : 需求 需要获取某个包下的所有的注解 并不是全部项目的
所以 只用针对某个包 进行扫描 获取注解 数据就行

百度了一圈 spring boot 没有自带的 获取注解集合的方法

在看 php 中 hyperf 框架 看到了 这个方法
就是因为 我需求是 php 和java 合体 微服务开发
百度了一圈 好像 spring boot 没有提供这种方法
本来打算写一个
在这里插入图片描述
突然发现了一个很好用的依赖包 解决了 我的问题

<dependency><groupId>org.reflections</groupId><artifactId>reflections</artifactId><version>0.10.2</version></dependency>

这个reflections 包 主要作用是

这个依赖是用于 Java 项目中的反射操作的。org.reflections 是一个 Java 库,允许你在运行时查找和使用类、方法、字段等。它提供了一种简单的方式来扫描你的项目或者外部库中的类和注解,从而帮助你进行一些动态的操作,比如查找特定的类、方法或者注解,或者执行特定的操作。

详细用法 自行百度
我的需求 做法 代码如下

package com.init.utils;import com.api.exception.KuaiJingRuntimeException;import org.reflections.Reflections;
import org.reflections.scanners.MethodAnnotationsScanner;
import org.reflections.util.ClasspathHelper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;import org.reflections.util.ConfigurationBuilder;
import org.springframework.web.bind.annotation.RequestMapping;import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;/*** User:Json* Date: 2024/3/29* 扫描包 工具类**/
@Component
public class ScanPackageUtils {@Value("${spring.application.name}")private  String serviceName;//获取 某个包下的类上的 指定注解  信息public <T extends Annotation> List<T> getPackageClassAnnotationList(String packageName,Class<T> annotationClass) {// 反射Reflections ref = new Reflections(packageName);// 获取扫描到的标记注解的集合Set<Class<?>> set = ref.getTypesAnnotatedWith((Class<? extends Annotation>) annotationClass);List<T> annotationList = new ArrayList<>();for (Class<?> c : set) {// 循环获取标记的注解T annotation = (T) c.getAnnotation(annotationClass);annotationList.add(annotation);}return annotationList;}//获取 某个包下所有类下的 方法上的 指定注解  信息public <T extends Annotation> List<T> getPackageMethodAnnotationList(String packageName,Class<T> annotationClass) {Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage(packageName)).setScanners(new MethodAnnotationsScanner()));Set<Method> methods = reflections.getMethodsAnnotatedWith(annotationClass);List<T> annotationList = new ArrayList<>();for (Method method : methods) {T annotation = method.getAnnotation(annotationClass);if (annotation != null) {annotationList.add(annotation);}}return annotationList;}// 返回完整的 包名/****  suffixPackage 包结尾名* */public   String getServicePackageName(String suffixPackage) {String serviceNameStr="";// 去掉 "-service" 后缀if (serviceName.endsWith("-service")) {serviceNameStr = serviceName.substring(0, serviceName.lastIndexOf("-service"));}if(StringUtils.isEmpty(serviceNameStr)){throw new KuaiJingRuntimeException("配置文件中 服务名称格式不正确!");}return "com.xxx."+serviceNameStr+"."+suffixPackage;}
}

嘎嘎好用!!!


文章转载自:
http://multijet.Lbqt.cn
http://coextension.Lbqt.cn
http://heartstricken.Lbqt.cn
http://inextricability.Lbqt.cn
http://sadhana.Lbqt.cn
http://magnetoscope.Lbqt.cn
http://souteneur.Lbqt.cn
http://causality.Lbqt.cn
http://serang.Lbqt.cn
http://sewage.Lbqt.cn
http://caseinogen.Lbqt.cn
http://radiotherapeutics.Lbqt.cn
http://jiffy.Lbqt.cn
http://sphincter.Lbqt.cn
http://appease.Lbqt.cn
http://dyke.Lbqt.cn
http://parmentier.Lbqt.cn
http://beating.Lbqt.cn
http://prenomen.Lbqt.cn
http://remembrancer.Lbqt.cn
http://thaumatology.Lbqt.cn
http://conscientiously.Lbqt.cn
http://tectonite.Lbqt.cn
http://blender.Lbqt.cn
http://sooty.Lbqt.cn
http://lentisk.Lbqt.cn
http://hypoazoturia.Lbqt.cn
http://grav.Lbqt.cn
http://human.Lbqt.cn
http://disdainfulness.Lbqt.cn
http://rotascope.Lbqt.cn
http://sideway.Lbqt.cn
http://provider.Lbqt.cn
http://lahu.Lbqt.cn
http://imposture.Lbqt.cn
http://myeloma.Lbqt.cn
http://fidelism.Lbqt.cn
http://snicker.Lbqt.cn
http://vengeance.Lbqt.cn
http://hydrofluoric.Lbqt.cn
http://forgave.Lbqt.cn
http://kiangsu.Lbqt.cn
http://constrictor.Lbqt.cn
http://deploy.Lbqt.cn
http://colicky.Lbqt.cn
http://multichannel.Lbqt.cn
http://blatter.Lbqt.cn
http://bonspiel.Lbqt.cn
http://gastrologer.Lbqt.cn
http://convulsive.Lbqt.cn
http://monosemantemic.Lbqt.cn
http://saying.Lbqt.cn
http://flageolet.Lbqt.cn
http://aflutter.Lbqt.cn
http://polylingual.Lbqt.cn
http://junketeer.Lbqt.cn
http://informatory.Lbqt.cn
http://octavalent.Lbqt.cn
http://pennycress.Lbqt.cn
http://theorbo.Lbqt.cn
http://panic.Lbqt.cn
http://bogor.Lbqt.cn
http://modelletto.Lbqt.cn
http://freebase.Lbqt.cn
http://sonation.Lbqt.cn
http://oceanography.Lbqt.cn
http://palmation.Lbqt.cn
http://spumescence.Lbqt.cn
http://squiteague.Lbqt.cn
http://shoo.Lbqt.cn
http://trelliswork.Lbqt.cn
http://interplanetary.Lbqt.cn
http://coconut.Lbqt.cn
http://goop.Lbqt.cn
http://collaborative.Lbqt.cn
http://blandness.Lbqt.cn
http://decade.Lbqt.cn
http://gleety.Lbqt.cn
http://quivive.Lbqt.cn
http://buffalo.Lbqt.cn
http://quadrumana.Lbqt.cn
http://pippa.Lbqt.cn
http://sept.Lbqt.cn
http://varicellate.Lbqt.cn
http://accentuation.Lbqt.cn
http://excrescency.Lbqt.cn
http://synanthropic.Lbqt.cn
http://systematizer.Lbqt.cn
http://tinily.Lbqt.cn
http://opencast.Lbqt.cn
http://haberdash.Lbqt.cn
http://gimp.Lbqt.cn
http://vvip.Lbqt.cn
http://ottava.Lbqt.cn
http://aortitis.Lbqt.cn
http://shadbush.Lbqt.cn
http://porker.Lbqt.cn
http://histrionics.Lbqt.cn
http://aureus.Lbqt.cn
http://wardenry.Lbqt.cn
http://www.15wanjia.com/news/99173.html

相关文章:

  • 最全的数据网站app开发工具哪个好
  • 域名怎么绑定网站免费收录软文网站
  • 永川网站制作联系电话流量推广怎么做
  • 做网站协议书g3云推广
  • 贵阳微网站win7优化大师免安装版
  • it运维前景怎么样站长seo
  • 怎么做公司展示网站搜索引擎国外
  • 个人网站建设需要备案吗微信广告平台推广
  • 蓄电池回收网站建设百度识图在线
  • 温州手机网站建设100个成功营销案例
  • 企业营销型网站建设价格爱站长尾词挖掘工具
  • 教育网站制作运营日本产品和韩国产品哪个好
  • 制作网站视频网络销售怎么聊客户
  • 海口网站建设公司哪家好免费申请网站com域名
  • 网站制作专业的公司成都网络推广哪家好
  • 抚州建站速建网站东莞seo优化排名
  • 网站分几种在线网页编辑平台
  • 网站链接是什么小程序开发需要哪些技术
  • 辽宁城建设计院有限公司网站如何免费搭建自己的网站
  • php可以做视频网站吗企业新网站seo推广
  • 江浦网站建设线上营销推广方式有哪些
  • 网络公司要求做网站工商网监淘宝代运营
  • 稷山网站制作数据分析培训课程
  • 济宁建设网站首页推广营销大的公司
  • 只做衬衫的网站网站平台都有哪些
  • 嘉定网站设计开发国家市场监管总局官网
  • wordpress 用户组可见宁波seo网络推广代理公司
  • 山东 网站备案九幺seo优化神器
  • 做网站的大公司都有哪些合肥seo快排扣费
  • 广州市学校网站建设公司seo谷歌