# jboot-kernel
**Repository Path**: jboot-org/jboot-kernel
## Basic Information
- **Project Name**: jboot-kernel
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2025-12-19
- **Last Updated**: 2025-12-24
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# JBoot Kernel
[](https://search.maven.org/search?q=g:org.jboot%20AND%20a:jboot-kernel)
[](http://www.apache.org/licenses/LICENSE-2.0)
[](https://www.oracle.com/java/technologies/javase-downloads.html)
JBoot Kernel 是一个基于 Spring Boot 的企业级微服务开发框架核心模块,提供了一整套完整的开发基础设施和工具集。
## 🚀 项目特性
- **模块化设计**:24+ 核心模块,按需依赖,灵活组合
- **微服务支持**:集成 Spring Cloud 生态,支持服务发现、配置管理、熔断限流
- **安全体系**:JWT 认证、数据权限、接口加密等全方位安全防护
- **数据库增强**:MyBatis Plus、多数据源、分布式事务支持
- **缓存方案**:Redis、EhCache 多级缓存,分布式锁支持
- **文件存储**:支持阿里云OSS、腾讯云COS、七牛云、MinIO等多种对象存储
- **开发工具**:代码生成器、Excel导入导出、API文档自动生成
- **监控运维**:集成 Prometheus、Actuator、链路追踪
## 📦 核心模块
### 基础支撑模块
- **kernel-bom**:Maven依赖版本管理
- **kernel-launch**:应用启动核心,统一启动器
- **kernel-toolkit**:通用工具类库,R统一API响应封装
- **kernel-core**:核心功能和常量定义
### 业务功能模块
- **kernel-secure**:安全认证模块,JWT Token管理
- **kernel-auth**:权限认证和授权
- **kernel-boot**:综合业务模块,集成常用功能
- **kernel-datascope**:数据权限控制
- **kernel-log**:日志管理和操作审计
### 微服务生态
- **kernel-cloud**:Spring Cloud微服务封装
- **kernel-nacos**:Nacos服务注册发现和配置中心
- **kernel-ribbon**:负载均衡
- **kernel-seata**:分布式事务
- **kernel-trace**:链路追踪
### 数据访问层
- **kernel-db**:数据库访问封装
- **kernel-mp**:MyBatis Plus增强
- **kernel-jpa**:JPA支持
- **kernel-redis**:Redis缓存和分布式锁
- **kernel-cache**:缓存抽象层
### 扩展功能模块
- **kernel-oss**:对象存储服务封装
- **kernel-excel**:Excel导入导出
- **kernel-swagger**:API文档生成
- **kernel-social**:第三方登录集成
- **kernel-sms**:短信服务
- **kernel-mail**:邮件服务
- **kernel-quartz**:定时任务调度
## 🛠 快速开始
### 1. 添加依赖
在你的 Spring Boot 项目中添加 JBoot Kernel 依赖:
```xml
org.jboot.platform
kernel-bom
2.1.14
pom
import
org.jboot
kernel-boot
2.1.14
```
### 2. 启动类配置
```java
@SpringBootApplication
// 微服务应用使用 @CloudApplication
// @CloudApplication
public class Application {
public static void main(String[] args) {
LaunchApplication.run("your-app-name", Application.class, args);
}
}
```
### 3. 配置文件示例
```yaml
spring:
datasource:
url: jdbc:mysql://localhost:3306/your_db
username: root
password: password
driver-class-name: com.mysql.cj.jdbc.Driver
jboot:
kernel:
secure:
enabled: true
redis:
enabled: true
oss:
enabled: true
name: minio
```
### 4. 统一响应封装
```java
@RestController
public class UserController {
@GetMapping("/user/{id}")
public R getUser(@PathVariable Long id) {
User user = userService.getById(id);
return R.data(user);
}
@PostMapping("/user")
public R createUser(@RequestBody User user) {
User result = userService.create(user);
return R.data(result, "创建成功");
}
}
```
## 💡 核心功能使用
### 安全认证
```java
@RestController
public class AuthController {
@PostMapping("/login")
public R login(@RequestBody LoginRequest request) {
// 验证用户信息
AuthUser authUser = userService.auth(request.getUsername(), request.getPassword());
// 生成Token
AuthInfo authInfo = SecureUtil.createAuthInfo(authUser, "default");
return R.data(authInfo);
}
@GetMapping("/user/current")
@PreAuth("hasRole('USER')")
public R getCurrentUser() {
AuthUser user = SecureUtil.getUser();
return R.data(user);
}
}
```
### 数据权限
```java
@Service
public class UserService {
@DataAuth(code = "user", column = "create_user_id", type = DataScopeEnum.OWN)
public List selectUserList() {
return userMapper.selectList(null);
}
}
```
### 缓存使用
```java
@Service
public class UserService {
@Cacheable(value = "user", key = "#id")
public User getUserById(Long id) {
return userMapper.selectById(id);
}
}
```
### Excel导入导出
```java
@RestController
public class ExcelController {
@PostMapping("/import")
public R> importExcel(@RequestParam MultipartFile file) {
List users = ExcelUtil.read(file, User.class);
userService.saveBatch(users);
return R.success("导入成功");
}
@GetMapping("/export")
public void exportExcel(HttpServletResponse response) {
List users = userService.list();
ExcelUtil.export(response, "用户列表", "用户数据", users, User.class);
}
}
```
## 🏗 微服务架构
### 服务注册发现
```java
@CloudApplication
public class UserServiceApplication {
public static void main(String[] args) {
LaunchApplication.run("user-service", UserServiceApplication.class, args);
}
}
```
### Feign客户端
```java
@FeignClient(name = "user-service")
public interface UserServiceClient {
@GetMapping("/api/user/{id}")
R getUserById(@PathVariable("id") Long id);
}
```
### 分布式事务
```java
@Service
public class OrderService {
@GlobalTransactional
public void createOrder(Order order) {
// 创建订单
orderMapper.insert(order);
// 扣减库存
inventoryService.deduct(order.getProductId(), order.getQuantity());
}
}
```
## 🔧 配置说明
### 数据库配置
```yaml
spring:
datasource:
url: jdbc:mysql://localhost:3306/jboot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: password
type: com.alibaba.druid.pool.DruidDataSource
druid:
initial-size: 5
min-idle: 5
max-active: 20
max-wait: 60000
```
### Redis配置
```yaml
spring:
redis:
host: localhost
port: 6379
password:
database: 0
jedis:
pool:
max-active: 20
max-idle: 10
min-idle: 5
```
### OSS配置
```yaml
oss:
enabled: true
name: minio # 支持aliyun、qiniu、tencent、minio
endpoint: http://localhost:9000
access-key: minioadmin
secret-key: minioadmin
bucket-name: jboot
```
## 📊 技术栈
- **核心框架**:Spring Boot 2.3.12、Spring Cloud Hoxton.SR11
- **数据库**:MySQL、PostgreSQL、Oracle、SQL Server
- **ORM框架**:MyBatis Plus 3.4.2、MyBatis-Flex 1.4.7
- **缓存**:Redis、EhCache
- **服务治理**:Nacos、Sentinel、Seata
- **API文档**:Swagger 2.10.5、Knife4j 2.0.9
- **对象存储**:阿里云OSS、腾讯云COS、七牛云、MinIO
- **监控**:Spring Boot Actuator、Prometheus
- **工具库**:Hutool 5.8.21、Guava 30.1.1
## 🤝 贡献指南
1. Fork 本仓库
2. 创建特性分支 (`git checkout -b feature/AmazingFeature`)
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
4. 推送到分支 (`git push origin feature/AmazingFeature`)
5. 创建 Pull Request
## 📄 开源协议
本项目基于 [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) 协议开源,请自由地享受和参与开源。
## 🔗 相关链接
- [Gitee仓库](https://gitee.com/jboot-org/jboot-kernel)
- [在线文档](https://jboot.org/docs)
- [问题反馈](https://gitee.com/jboot-org/jboot-kernel/issues)
- [更新日志](CHANGELOG.md)
## 💬 联系我们
- **邮箱**:peng.deyou@139.com
- **QQ群**:[点击链接加入QQ群](https://jq.qq.com/?_wv=1027&k=5tK8qQr)
- **微信群**:扫描下方二维码加入
---
⭐ 如果这个项目对你有帮助,请给我们一个 Star!