Skip to content

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

License

Notifications You must be signed in to change notification settings

jujunchen/spring-hot-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

7385283 · Sep 8, 2024

History

93 Commits
Jun 27, 2024
Jul 27, 2024
Sep 8, 2024
Sep 8, 2024
Sep 8, 2024
Sep 8, 2024
Sep 8, 2024
Sep 8, 2024
Sep 3, 2024
Jun 27, 2024
Jul 27, 2024
Sep 8, 2024
Sep 8, 2024

Repository files navigation

Spring 插件化开发框架

🤔Reporting Issues 📘English Documentation

license build jdk hutool

介绍

基于Spring 的插件化开发框架,轻、快、易、稳,无需暴露核心模块代码,降低代码耦合,热加载动态更新,提高开发效率。

轻:轻量

快:启动速度快

易:使用简单,原生spring编程

稳:稳定,兼容性强

支持特性

v1.2(开发中)

  • 支持分布式部署
  • 支持freemarker模板引擎

v1.1

  • 支持插件中使用第三方依赖,jar、dll文件
  • 支持Mybatis、MybatisPlus

v1.0

  • 支持子类引用父类Spring Bean
  • 插件代码与主程序代码隔离
  • 支持热加载普通类、各类Spring Bean
  • 支持热加载Controller控制器
  • 支持热加载定时任务
  • 支持插件中使用第三方依赖
  • 支持主程序监听插件启动卸载事件

原理

架构图

基于Spring的 applicationContext 和 classLoader 对插件中的类进行热加载,卸载的时候尽可能的销毁引用,避免内存泄露。

安装教程

  • spring-hot-plugin-common 插件公共包
  • spring-hot-plugin-core 插件核心包
  • spring-hot-plugin-loader 插件依赖加载包
  • spring-hot-plugin-maven 插件maven打包工具
  • spring-hot-plugin-mybatis 插件mybatis依赖包
  • spring-hot-plugin-example 插件示例项目

Maven 安装

使用controller、定时任务、第三方依赖

<!--引入插件核心包-->
<dependency>
    <groupId>vip.aliali.spring</groupId>
    <artifactId>spring-hot-plugin-core</artifactId>
    <version>${lastVersion}</version>
</dependency>

使用mybatis、mybatis-plus

<!--引入mybatis依赖包-->
<dependency>
    <groupId>vip.aliali.spring</groupId>
    <artifactId>spring-hot-plugin-mybatis</artifactId>
    <version>${lastVersion}</version>
</dependency>

源码构建

  1. git clone 本项目
  2. IDEA导入项目,根目录运行 mvn clean install(或者上传到私服)
  3. 主程序中引入插件核心包,修改版本为最新版本
<!--引入插件核心包-->
<dependency>
    <groupId>csdn.itsaysay.plugin</groupId>
    <artifactId>spring-hot-plugin-core</artifactId>
    <version>${lastVersion}</version>
</dependency>
  1. 其他按需引入依赖

使用说明

  1. 在主程序pom.xml中引入插件依赖
  2. 在主程序中,参考spring-hot-plugin-demo项目创建一个安装插件的接口
  3. 配置插件
plugin:
  #是否启用插件功能
  enable:
  #运行模式,开发环境: dev,生产环境: prod
  runMode:
  #在卸载插件后, 备份插件的目录
  backupPath:
  #插件的路径,如果插件路径下存在插件会自动加载
  pluginPath:
  #扫描的包路径
  basePackage:
  1. 插件开发
  • 参考plugin-demo,将主程序以<scope>provided</scope>的生命周期引入maven,这样就可以在插件中引用主程序的Bean。 其他就如同平时开发方式一样
  • 打包工具,同样参考plugin-demo 的 pom文件配置 spring-hot-plugin-maven
  1. 安装插件
  • 通过前面创建的接口进行动态安装,选择-repackage结尾的jar包(推荐
  • 直接放入插件安装目录,需要重启主程序

参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages