Skip to content

⭐️⭐️⭐️⭐️⭐️Spring plugin development framework, Light, Fast, Easy, and StableSpring 插件化开发框架,轻、快、易、稳 ⭐️⭐️⭐️⭐️⭐️

License

Notifications You must be signed in to change notification settings

jujunchen/spring-hot-plugin

Repository files navigation

Spring Plugin Development Framework

🤔Reporting Issues 📘中文

license build jdk hutool

Introduction

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

Supported Features

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

Principle

Architecture Diagram

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.

Installation Guide

  • 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

Maven Installation

Using controller, scheduled tasks, third-party dependencies

<!--Introduce plugin core package-->
<dependency> 
    <groupId>vip.aliali.spring</groupId> 
    <artifactId>spring-hot-plugin-core</artifactId> 
    <version>${lastVersion}</version> 
</dependency>

Using Mybatis, Mybatis-plus

<!--Introduce mybatis dependency package-->
<dependency> 
    <groupId>vip.aliali.spring</groupId> 
    <artifactId>spring-hot-plugin-mybatis</artifactId> 
    <version>${lastVersion}</version> 
</dependency>

Source Code Build

  1. git clone this project
  2. Import the project in IDEA, run mvn clean install in the root directory (or upload to a private repository)
  3. 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>
  1. Introduce other dependencies as needed

Usage Instructions

  1. Introduce plugin dependencies in the main program's pom.xml
  2. In the main program, refer to the spring-hot-plugin-demo project to create an interface for installing plugins
  3. 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:
  1. 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 for spring-hot-plugin-maven
  1. 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

Performance Test

Test Case: Simulate frequent plugin installation, uninstallation, and data operations to observe memory consumption.

Docker container maximum memory: 256MB

  1. Install plugin-demo-mybatis plugin
  2. Add data
  3. Query data
  4. Delete data
  5. Uninstall plugin-demo-mybatis plugin

img.png

Contribution

  1. Fork this repository
  2. Create a new Feat_xxx branch
  3. Submit code
  4. Create a Pull Request

About

⭐️⭐️⭐️⭐️⭐️Spring plugin development framework, Light, Fast, Easy, and StableSpring 插件化开发框架,轻、快、易、稳 ⭐️⭐️⭐️⭐️⭐️

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published