The Java ServiceLoader needs these entries to be present in the JAR file. Is there a way to programmatically add these runtime service records for unit testing when inside an IDE? Especially when JARs are not yet built.
Do not go in cycles in JAR files. They are the preferred way to encapsulate services, but they are not required. The key really ClassLoader.getResources(String)is where arg Stringeffectively becomes ("META-INF/services/" + serviceClass.getName()). Another bit of information to keep in mind is what the context class loaderServiceLoader.load(Class) uses (of course, you can also use ). So ... what you really need to do is to manipulate the class of the classes or configure the context class loader to make it happy.ServiceLoader.load(Class, ClassLoader)ServiceLoader
ClassLoader.getResources(String)
String
("META-INF/services/" + serviceClass.getName())
ServiceLoader.load(Class)
ServiceLoader.load(Class, ClassLoader)
ServiceLoader
Source: https://habr.com/ru/post/1752511/More articles:Zip function for shell scripts - pythonASP.NET MVC 2: ViewData.Model.ExecuteResult does not exist - asp.net-mvccheckboxes within range, select snapshot - javascriptКак анализировать журналы чатов Gmail с веб-страницы? - htmlHow to apply style to the nth instance of a class and find it by indirect inheritance - CSS JQuery - jqueryHow to pass a specific argument to a decorator in python - functionAdding a custom WCF header to the endpoint to ensure reliable sessions - headercapistrano deploy: доступ запрещен для пользователя "root" @ "localhost" (с использованием пароля: YES) (Mysql:: Error) - mysqlDoes jQuery slider start from above? - jqueryWxPython: wx.ListItem output, but wx.ListCtrl only returns the old class - pythonAll Articles