A lightweight, fast, easy, and stable Spring-based plugin development framework. It does not require exposing core module code, reduces code coupling, supports hot reloading for dynamic updates, and improves development efficiency.
Lightweight: Lightweight
Fast: Fast startup
Easy: Easy to use, native Spring programming
Stable: Stable, strong compatibility
v1.2 (Under Development)
- Support for distributed deployment
- Support for Freemarker template engine
v1.1.1
- Support for using third-party dependencies in plugins, including jar and dll files
- Support for MyBatis and MyBatisPlus
v1.0
- Support for subclasses referencing parent Spring Beans
- Isolation of plugin code from main program code
- Support for hot reloading of ordinary classes and various Spring Beans
- Support for hot reloading of Controller controllers
- Support for hot reloading of scheduled tasks
- Support for using third-party dependencies in plugins
- Support for the main program to listen to plugin startup and uninstallation events
Based on Spring's applicationContext and classLoader, hot reloading of classes in plugins is performed. During uninstallation, efforts are made to cut off GC ROOTs to avoid memory leaks.
- spring-hot-plugin-common: Plugin common package
- spring-hot-plugin-core: Plugin core package
- spring-hot-plugin-loader: Plugin dependency loading package
- spring-hot-plugin-maven: Plugin Maven packaging tool
- spring-hot-plugin-mybatis: Plugin MyBatis dependency package
- spring-hot-plugin-example: Plugin example project
<!--Introduce plugin core package-->
<dependency>
<groupId>vip.aliali.spring</groupId>
<artifactId>spring-hot-plugin-core</artifactId>
<version>${lastVersion}</version>
</dependency>
<!--Introduce mybatis dependency package-->
<dependency>
<groupId>vip.aliali.spring</groupId>
<artifactId>spring-hot-plugin-mybatis</artifactId>
<version>${lastVersion}</version>
</dependency>
- git clone this project
- Import the project in IDEA, run
mvn clean install
in the root directory (or upload to a private repository) - Introduce the plugin core package in the main program, modify the version to the latest version
<!--Introduce plugin core package-->
<dependency>
<groupId>csdn.itsaysay.plugin</groupId>
<artifactId>spring-hot-plugin-core</artifactId>
<version>${lastVersion}</version>
</dependency>
- Introduce other dependencies as needed
- Introduce plugin dependencies in the main program's pom.xml
- In the main program, refer to the
spring-hot-plugin-demo
project to create an interface for installing plugins - Configure the plugin
plugin:
#Whether to enable plugin functionality
enable:
#Run mode, development environment: dev, production environment: prod
runMode:
#Backup directory after uninstalling the plugin
backupPath:
#Plugin path, if the plugin path exists, it will be automatically loaded
pluginPath:
#Package path to scan
basePackage:
- Plugin Development
- Refer to
plugin-demo
, introduce the main program with<scope>provided</scope>
lifecycle in Maven, so that the plugin can reference the main program's Beans. Other development methods are the same as usual- Packaging tool, refer to the pom file configuration of
plugin-demo
forspring-hot-plugin-maven
- Install Plugin
- Perform
dynamic
installation through the previously created interface, select the jar package with-repackage
suffix (Recommended) - Directly place it in the plugin installation directory, requires restarting the main program
Test Case: Simulate frequent plugin installation, uninstallation, and data operations to observe memory consumption.
Docker container maximum memory: 256MB
- Install plugin-demo-mybatis plugin
- Add data
- Query data
- Delete data
- Uninstall plugin-demo-mybatis plugin
- Fork this repository
- Create a new Feat_xxx branch
- Submit code
- Create a Pull Request