java插件式开发框架_springboot插件式开发框架

springboot插件式开发框架

介绍

该框架主要是集成于springboot项目,用于开发插件式应用的集成框架。

核心功能

插件配置式插拔于springboot项目。

在springboot上可以进行插件式开发, 扩展性极强, 可以针对不同项目开发不同插件, 进行不同插件jar包的部署。

可通过配置文件指定要启用或者禁用插件。

支持上传插件和插件配置文件到服务器, 并且无需重启主程序, 动态部署插件、更新插件。

支持查看插件运行状态, 查看插件安装位置。

无需重启主程序, 动态的安装插件、卸载插件、启用插件、停止插件、备份插件、删除插件。

在插件应用模块上可以使用Spring注解定义组件, 进行依赖注入。

支持在插件中开发Rest接口。

支持在插件中单独定义持久层访问等需求。

可以遵循主程序提供的插件接口开发任意扩展功能。

插件可以自定义配置文件。目前只支持yml文件。

支持自定义扩展开发接口, 使用者可以在预留接口上扩展额外功能。

利用扩展机制, 定制了SpringBoot-Mybatis扩展包。使用该扩展包, 使用者可以在插件中自定义Mapper接口、Mapper xml 以及对应的实体bean。

运行环境

jdk1.8+

apache maven 3.6

mavne 仓库地址

快速入门

新建项目。

Maven目录结构下所示

-example

- example-runner

- pom.xml

- example-main

- pom.xml

- example-plugin-parent

- pom.xml

- plugins

- example-plugin1

- pom.xml

- plugin.properties

- example-plugin2

- pom.xml

- plugin.properties

- pom.xml

- pom.xml

结构说明:

pom.xml 代表maven的pom.xml

plugin.properties 为开发环境下, 插件的元信息配置文件, 配置内容详见下文。

example 为项目的总Maven目录。

example-runner 在运行环境下启动的模块。主要依赖example-main模块和插件中使用到的依赖包。

example-main 该模块为项目的主程序模块。

example-plugin-parent 该模块为插件的父级maven pom 模块, 主要定义插件中公共用到的依赖, 以及插件的打包配置。

plugins 该文件夹下主要存储插件模块。上述模块中主要包括example-plugin1、example-plugin2 两个插件。

example-plugin1、example-plugin2 分别为两个插件Maven包。

主程序集成步骤

主程序为上述目录结构中的 example-main 模块。

在主程序中新增maven依赖包

com.gitee.starblues

springboot-plugin-framework

${springboot-plugin-framework.version}

实现并定义配置

实现 com.plugin.development.integration.IntegrationConfiguration 接口。

import com.gitee.starblues.integration.DefaultIntegrationConfiguration;

import org.pf4j.RuntimeMode;

import org.springframework.beans.factory.annotation.Value;

import org.springframework.boot.context.properties.ConfigurationProperties;

import org.springframework.stereotype.Component;

@Component

@ConfigurationProperties(prefix = "plugin")

public class PluginConfiguration extends DefaultIntegrationConfiguration {

/**

* 运行模式

* 开发环境: development、dev

* 生产/部署 环境: deployment、prod

*/

@Value("${runMode:dev}")

private String runMode;

/**

* 插件的路径

*/

@Value("${pluginPath:plugins}")

private String pluginPath;

/**

* 插件文件的路径

*/

@Value("${pluginConfigFilePath:pluginConfigs}")

private String pluginConfigFilePath;

@Override

public RuntimeMode environment() {

return RuntimeMode.byName(runMode);

}

@Override

public String pluginPath() {

return pluginPath;

}

@Override

public

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值