ServiceLoader to find implementations of an interface

后端 未结 3 2224
孤街浪徒
孤街浪徒 2020-12-24 03:39

I tried to use the Java ServiceLoader to find all classes that implement a specific interface like so:

loader = ServiceLoader.load(Operation.class);
try {
           


        
3条回答
  •  萌比男神i
    2020-12-24 04:03

    In order to scan your classpath at runtime for implementations of specific interface you would need to use different solution eg. Reflections (notice s on the end, this is not java's Reflection API)

提交回复
热议问题