1 Star 4 Fork 2

Wiki / sweet-plugin

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

简介

Sweet-Plugin是基于Spring Boot开发的插件管理框架,采用sidecar边车运行模式,与主程序一起启动,但具有自己的生命周期,可以动态安装、卸载、启动和停止插件功能。

技术架构

特性

  • 插件采用标准的SpringBoot Application开发和运行,具有独立、完整的生命周期管理;
  • 主程序ApplicationContext插件ApplicationContext完全隔离,通过扩展接口进行通讯;
  • 使用maven打包插件,支持对插件的自主打包编译,支持打包成jar、zip和文件夹多种方式;
  • 插件具有独立的类加载器,支持插件定义各种的依赖jar包;
  • 插件可以使用主程序的类包;
  • 插件可以使用主程序的环境变量和yml配置参数;
  • 插件可以定义@Autowired优先级别,例如:优先主程序后插件、优先插件后主程序、只查找插件等;
  • 插件可以通过@Extension主程序暴露实现;
  • 插件支持自定义@Controller控制器,同时监听插件生命周期自动卸载和启用;
  • 插件支持AOP工厂,动态扩展业务功能,同时监听插件生命周期自动卸载和启用;
  • 插件支持插件工厂,动态扩展一组业务功能,同时监听插件生命周期自动卸载和启用;

使用方法

1)引入依赖

修改pom.xml,引入sweet-plugin-spring-boot-starter包

<dependency>
    <groupId>com.gitee.bluesweeter</groupId>
    <artifactId>sweet-plugin-spring-boot-starter</artifactId>
    <version>发布版本>=1.2.2</version>
</dependency>

2)在SpringBoot启动类中加入@EnableEgdPlugin启动插件机制

@SpringBootApplication
@EnableEgdPlugin
public class SweetApiWebApplication {
    public static void main(String[] args) {
        SpringApplication.run(SweetApiWebApplication.class, args);
    }
}

3)引入需要插件

插件运行文件夹默认在classes/plugins文件夹中,需要修改pom.xml:

第一步,先引入插件,例如:以下引入开发好的restful插件,以zip格式

<dependencies>
    ...
    <dependency>
        <groupId>com.egrand.sweetapi.plugin</groupId>
        <artifactId>sweet-api-plugin-restful</artifactId>
        <version>1.2.1-SNAPSHOT</version>
        <type>zip</type>
    </dependency>
    ...
</dependencies>

第二步,增加一个maven-dependency-plugin插件声明,将zip文件复制到classes/plugins文件夹中

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.8</version>
        <executions>
            <!--导出所有的 jar 包-->
            <execution>
                <id>plugin-process-resources</id>
                <goals>
                    <goal>copy-dependencies</goal>
                </goals>
                <!-- (打包阶段):在实际打包中,执行任何的必要的操作。 -->
                <phase>process-resources</phase>
                <configuration>
                    <outputDirectory>${project.build.directory}/classes/plugins</outputDirectory>
                    <stripVersion>false</stripVersion>
                    <includeTypes>zip</includeTypes>
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>
MIT License Copyright (c) 2023 Wiki Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Sweet-Plugin是基于Spring Boot开发的插件管理框架,采用SideCar边车运行模式,与主程序一起启动,但具有自己的生命周期,支持动态安装、卸载、启动和停止插件功能。 展开 收起
Java
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/bluesweeter/sweet-plugin.git
git@gitee.com:bluesweeter/sweet-plugin.git
bluesweeter
sweet-plugin
sweet-plugin
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891