如果我传递空,那么org.reflections会从哪个包中获取?(Where org.reflections takes package from if i pass empty?)

编程入门 行业动态 更新时间:2024-10-28 12:29:23
如果我传递空,那么org.reflections会从哪个包中获取?(Where org.reflections takes package from if i pass empty?)

我在使用反射时遇到问题。 我在一个项目中有这个代码,它被其他项目实现为maven依赖,以查找testNG测试类。 所以,因为我没有得到一个特定的包,我把它传递给空,它在我本地执行时找到了我想要的成功类。 这是我的代码:

String pack = StringUtils.EMPTY; this.reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage(pack)).setScanners( new MethodAnnotationsScanner())); this.testNGTests = this.reflections.getMethodsAnnotatedWith(org.testng.annotations.Test.class);

但我有一个问题,当我远程执行它时,它找不到任何类。 所以我在想我必须在包参数中传递一些东西。 所以,我想知道你们是否有任何想法,当我通过空包时为什么会发生反应。 你知道什么可以帮助我吗? 谢谢!

i am having a problem when using reflections. I have this code in a project, which is implemented as maven dependency by other projects to find testNG test classes. So, as i haven't got a particular package, i was passing it empty and it was finding successfully classes i want when i execute locally. Here is my code:

String pack = StringUtils.EMPTY; this.reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage(pack)).setScanners( new MethodAnnotationsScanner())); this.testNGTests = this.reflections.getMethodsAnnotatedWith(org.testng.annotations.Test.class);

But i have the problem that when i execute it remotely it can't find any classes. So i was thinking that i must pass it something at package parameter. So, i want to know if any of you have and idea about that happens behind reflections when i pass empty package and why is working. Do you know something that could help me? Thank you!

最满意答案

我已经解决了我的问题。 我通过forJavaClassPath更改了package的设置。 谢谢! 然而,如果你们中的任何人能够给我更多的信息,那么它将会很好地收到! 问候

I've already fixed my problem. I changed the setting for package by forJavaClassPath. Thanks you! Yet, if any of you could give me some more information it will be well recieved! Regards

更多推荐

本文发布于:2023-07-26 06:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1272222.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:包中   reflections   org   takes   empty

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!