Is there a pattern for dynamically loadable modules in Spring Boot?

◇◆丶佛笑我妖孽 提交于 2019-12-03 03:59:49
gtonic

I'm afraid there isn't a 100% solution. There's maybe some options; let me highlight the following three:

  1. There are Spring factories, a way to (auto-)configure your beans.

  2. Another interesting approach to go is the way of how Spring Boot handles extensions by itself - by having its own spring-boot-starters, like in this article: https://blog.codecentric.de/en/2014/11/extending-spring-boot-five-steps-writing-spring-boot-starter/, combined with Spring Factories you could

  3. The most plugin-like solution is the spring-plugin-project. However it looks like only loading is supported, some other features like versioning are missing, too. So you probably have to build it by yourself.

So the main problem might be in unloading and updating these things at runtime, which leads me to the final observation:

In general I have the impression that the concept of having a plugin is working a bit against the idea of Spring Boot, as it is designed for microservice architectures. So the added (plugin) functionality probably would rather be a separate microservice (with its own storage) which gets orchestrated by a gateway, here let me highlight the spring-boot-based JHipster project to show the idea of such an architecture.

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