hank-cp/sbp
Fork: 68 Star: 216 (更新于 2024-12-15 12:40:42)
license: Apache-2.0
Language: Java .
Plugin framework for Spring Boot based on pf4j.
最后发布版本: 25 ( 2024-06-26 01:29:36)
sbp introduce plugin oriented programming to Spring Boot. It is inspired and builds on top of Pf4j project.
❗️❗️❗️sbp supports Spring Boot 3.x ONLY from version 18. If you are still using Spring Boot 2.x, please stay with the old version of sbp.
Why we need plugin for Spring Boot?
- Spring boot is good, but it is monolithic. It means you have to delivery the whole application for every single code change every time.
- We need a modern framework with flexibility and extensibility to rapidly deliver solution for complex business scenario.
- Not all projects need to consider scaling at the beginning stage, like Spring Cloud does.
- With sbp, we could think in micro service architecture only with Spring Boot, but no need to worried too much about "cloud native" things, like service discovery, traffic control, etc.
- It's a medium level preference between monolithic Spring Boot application and distributed Spring Cloud application.
Feature / Benefits
-
Turn monolithic Spring Boot application to be MODULAR.
-
Much more LIGHTWEIGHT development and deployment for spiral extensible architecture.
-
Install/update/start/stop plugins ON THE FLY.
-
FULL STACK Web/Rest server-side features powered by Spring Boot, including:
- Controller/RestController
- RouterFunction
- WebFlux
- static resource mapping, including template engine like Freemarker/Velocity/Thymeleaf
- persistence (Spring Data/JPA/Jooq/Mybatis/Plain SQL)
- Spring Security
- AOP
-
Code and test plugin project as STANDALONE Spring Boot project.
-
Supports Spring Boot from
2.x
to3.2.x
-
NO extra knowledge NEED TO LEARN as long as you are familiar with Spring Boot.
-
NO XML
vs OSGi Based Server (Eclipse Virgo \ Apache Karaf)
- OSGi based server need a server container to deploy, which is not cloud friendly.
- OSGi configuration is complex and strict, the learning curve is steep.
- Bundle cannot be run standalone, which is hard for debug and test.
-
Spring dm server has been dead, and its successor Virgo is now still struggling to live.
vs Spring Cloud
- Spring Cloud does not aim to solve similar problem as
sbp
, but so far it maybe the best choice to solve application extension problem. - With sbp, you will no need to consider too much about computer resource arrangement, everything stick tight within one process.
- Again, sbp is good for medium level applications, which have problem to handle business change rapidly. For large scale application, Spring Cloud is still your best choice.
- sbp should be able to live with Spring Cloud. After all, it is still a Spring Boot application, just like any single service provider node in Spring Cloud network.
Getting Started
Create app project
- Create a Spring Boot project with multi sub project structure.
- For Gradle, it means multiple projects
- For Maven, it means multiple modules
- Take the demo projects for reference.
- Introduce
sbp-spring-boot-starter
to dependencies.- Maven
<dependency> <groupId>org.laxture</groupId> <artifactId>sbp-spring-boot-starter</artifactId> <version>3.3.25</version> </dependency>
- Gradle
dependencies { implementation "org.springframework.boot:spring-boot-starter-web" implementation "org.springframework.boot:spring-boot-starter-aop" implementation 'org.laxture:sbp-spring-boot-starter:3.3.25' }
- Latest master code is always available with version
-SNAPSHOT
- Maven
- Add belows to
application.properties
.spring.sbp.runtimeMode = development spring.sbp.enabled = true # remember to add this line in case you are using IDEA spring.sbp.classes-directories = "out/production/classes, out/production/resources"
- Add anything you want in this project like
Controller
,Service
,Repository
,Model
, etc. - Create an empty folder named
plugins
.
Create plugin project
- Create a plain Spring Boot project in the
plugins
folder. - Add
plugin.properties
file to the plugin project.plugin.id=<> plugin.class=demo.sbp.admin.DemoPlugin plugin.version=0.0.1 plugin.provider=Your Name plugin.dependencies=
- Introduce
sbp-core
to dependencies.- Maven
<dependency> <groupId>org.laxture</groupId> <artifactId>sbp-core</artifactId> <version>3.3.25</version> </dependency>
- Gradle
dependencies { implementation 'org.laxture:sbp-core:3.3.25' }
- Maven
- Add Plugin class
public class DemoPlugin extends SpringBootPlugin { public DemoPlugin(PluginWrapper wrapper) { super(wrapper); } @Override protected SpringBootstrap createSpringBootstrap() { return new SpringBootstrap(this, AdminPluginStarter.class); } }
- Add anything you want in the plugin project like
Controller
,Service
,Repository
,Model
, etc.
Everything is done and now you could start the app project to test the plugin.
Documentation
- How it works
- Configuration
- Serve Static Content
- Extensible Integration
- Security / AOP
- Deployment
- Support Different Spring Boot Versions
- Trouble Shoot & Misc
- How to run
- Road map
License
/*
* Copyright (C) 2019-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
最近版本更新:(数据更新于 2024-10-24 22:31:27)
2024-06-26 01:29:36 25
2024-04-17 17:17:38 24
2024-04-11 04:45:29 23
2023-10-09 18:47:17 22
2023-09-19 17:23:45 21
2023-05-25 01:56:25 20
2023-05-23 23:45:31 19
2023-04-26 14:34:54 18
2023-02-02 17:49:09 17
2023-01-30 03:00:13 16
主题(topics):
pf4j, plugin, plugins, sbp, sping, spring-boot
hank-cp/sbp同语言 Java最近更新仓库
2024-12-20 19:54:15 mybatis-flex/mybatis-flex
2024-12-19 21:53:46 spring-projects/spring-boot
2024-12-19 21:25:16 Stirling-Tools/Stirling-PDF
2024-12-19 16:28:14 Tornaco/Thanox
2024-12-19 10:42:01 alibaba/nacos
2024-12-18 20:58:34 dromara/forest