@ServiceProvider(ServiceInterface.class) public class ServiceImplementation implements ServiceInterface { // ... } public class Main { public static void main(String[] args) { ServiceLoader<ServiceInterface> loader = ServiceLoader.load(ServiceInterface.class); for (ServiceInterface service : loader) { service.doSomething(); } } } com.example.ServiceInterface=com.example.ServiceImplementation


上一篇:
下一篇:
切换中文