简体   繁体   English

Spring Boot:在类路径更改中刷新应用程序上下文

[英]Spring Boot: Refresh Application Context on Classpath Changes

I've built a small Application using Spring Boot's PropertiesLauncher in conjunction with Loader-Path: plugins Manifest Entry. 我使用Spring Boot的PropertiesLauncherLoader-Path: plugins Manifest Entry构建了一个小型应用程序。 There are several jar files inside the plugins folder containing META-INF/spring.factories . plugins文件夹中有几个包含META-INF/spring.factories jar文件。

Loading the Configuration of my external plugin jars works as expected. 加载我的外部插件罐的配置按预期工作。

Now I wonder if and how I could refresh the application context if something on the classpath changes. 现在我想知道如果类路径上的某些内容发生变化,我是否以及如何刷新应用程序上下文。 For example deleting or adding an external plugin jar. 例如,删除或添加外部插件jar。

I've already took a look into SpringApplicationRunListener but I guess I cannot realize it with this class. 我已经看过SpringApplicationRunListener,但我想我无法用这个类实现它。

Any ideas if and how it is possible? 任何想法是否以及如何可能?

With plain Spring changing jars on the class path usually means full application restart. 使用普通的Spring更改类路径上的jar通常意味着完全重启应用程序。 There is no out of the box mechanism to support runtime changes in the class path provided Spring Framework. 没有开箱即用的机制来支持Spring Framework提供的类路径中的运行时更改。

In 2009/2010 there was Spring Dynamics Modules project but it seems abandoned now . 在2009/2010年,有Spring Dynamics Modules项目,但现在似乎已经放弃了

You most likely would have to implement this from scratch yourself. 你很可能必须自己从头开始实现这一点。 Perhaps you should look into an existing plugin system implementation eg Apache Felix which implements OSGi : 也许您应该研究现有的插件系统实现,例如实现OSGi的 Apache Felix

Apache Felix is a community effort to implement the OSGi Framework and Service platform and other interesting OSGi-related technologies under the Apache license. Apache Felix是一项社区工作,旨在根据Apache许可证实施OSGi框架和服务平台以及其他有趣的OSGi相关技术。 The OSGi specifications originally targeted embedded devices and home services gateways, but they are ideally suited for any project interested in the principles of modularity, component-orientation, and/or service-orientation. OSGi规范最初针对嵌入式设备和家庭服务网关,但它们非常适合任何对模块化,组件定位和/或面向服务原则感兴趣的项目。 OSGi technology combines aspects of these aforementioned principles to define a dynamic service deployment framework that is amenable to remote management. OSGi技术结合了上述原则的各个方面,以定义适合远程管理的动态服务部署框架。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM