Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.util.ServiceLoader.load()函数无效,只返回空结果_Java_Scala_Reflection_Serviceloader - Fatal编程技术网

java.util.ServiceLoader.load()函数无效,只返回空结果

java.util.ServiceLoader.load()函数无效,只返回空结果,java,scala,reflection,serviceloader,Java,Scala,Reflection,Serviceloader,我试图使用Scala 2.10中的Java ServiceLoader通过反射查找我的所有测试类: val services = ServiceLoader.load(classOf[MyClass]) for (service <- services.asScala) { test(service.getClass.getCanonicalName) { println(service) ... test code } } Servi

我试图使用Scala 2.10中的Java ServiceLoader通过反射查找我的所有测试类:

  val services = ServiceLoader.load(classOf[MyClass])
  for (service <- services.asScala) {
    test(service.getClass.getCanonicalName) {
      println(service)
      ... test code
    }
  }

ServiceLoader在Scala中不工作吗?如何修复或避免此问题?

很抱歉,我忘记设置META-INF/services/文件,在添加服务类的二进制名称后,一切正常

您甚至没有显示足够的代码来查看“空测试套件”消息的来源。如果一开始就转储
服务
,会发生什么情况?你试过交互式调试吗?你的
META-INF/services/
文件在哪里?你是对的,META-INF/services/丢失了,看起来它不是一个完全自动的类检测器。空的测试套件消息由scala test在loopExplain如何处理服务文件夹中抛出
Empty test suite.