我在使用反射时遇到问题。 我在一个项目中有这个代码,它被其他项目实现为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
更多推荐
发布评论