Where to put ServiceLoader config file in a web app

◇◆丶佛笑我妖孽 提交于 2019-12-01 04:23:13

The META-INF/services should be at the root of the jar file or resource directory in the classpath of the classloader used to locate plugins.

If you have a web application, then you can have directory structure like:

<webappname>/WEB-INF/classes/META-INF/services

But the ideal way is to have it in your plugin's jar file. E.g if you have a plugin bundled as WEB-INF/lib/myplugin.jar, and your plugin class is com.example.plugin.MyPlugin Then the jar should have a structure:

myplugin.jar!/META-INF/services/com.example.plugin.MyPlugin

Having done that, you can get a service loader using your web application's class loader

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!