{"id":22929632,"url":"https://github.com/lwohvye/unicorn","last_synced_at":"2025-04-06T10:11:08.552Z","repository":{"id":37044903,"uuid":"350562833","full_name":"lWoHvYe/unicorn","owner":"lWoHvYe","description":"基于最新的Java 21和SpringBoot 3.4。根据eladmin项目进行改造。整合常用的Components.","archived":false,"fork":false,"pushed_at":"2025-03-26T17:51:40.000Z","size":22540,"stargazers_count":42,"open_issues_count":2,"forks_count":22,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-30T09:05:45.808Z","etag":null,"topics":["gradle","java","jpa","kotlin","lwohvye","oauth2","spring-boot","spring-security","unicorn","virtual-threads","websocket"],"latest_commit_sha":null,"homepage":"https://lwohvye.github.io/unicorn/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lWoHvYe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"otechie":"c9635b6fcfabfeed","custom":"https://aurora-1255840532.cos.ap-chengdu.myqcloud.com/donation.png"}},"created_at":"2021-03-23T03:04:54.000Z","updated_at":"2025-03-28T21:24:06.000Z","dependencies_parsed_at":"2023-09-21T17:09:18.124Z","dependency_job_id":"63f87c4b-635e-41d5-9828-fc93a5cb6d3e","html_url":"https://github.com/lWoHvYe/unicorn","commit_stats":{"total_commits":2139,"total_committers":42,"mean_commits":50.92857142857143,"dds":"0.33099579242636745","last_synced_commit":"63277226c329201ae575d26d1f5b8f31d405c5b1"},"previous_names":["lwohvye/eladmin"],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lWoHvYe%2Funicorn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lWoHvYe%2Funicorn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lWoHvYe%2Funicorn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lWoHvYe%2Funicorn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lWoHvYe","download_url":"https://codeload.github.com/lWoHvYe/unicorn/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247464220,"owners_count":20942970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gradle","java","jpa","kotlin","lwohvye","oauth2","spring-boot","spring-security","unicorn","virtual-threads","websocket"],"created_at":"2024-12-14T10:15:37.096Z","updated_at":"2025-04-06T10:11:08.516Z","avatar_url":"https://github.com/lWoHvYe.png","language":"Java","funding_links":["https://otechie.com/c9635b6fcfabfeed","https://aurora-1255840532.cos.ap-chengdu.myqcloud.com/donation.png"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"document/images/chaste unicorn.png\" width=\"200\" style=\"vertical-align:middle;\" alt=\"Chaste Unicorn\"\u003e \n  \u003cspan style=\"color:#b700ff;font-size: 80px;font-weight:bold\"\u003eUnicorn\u003c/span\u003e  \n\u003c/div\u003e\n\u003cdiv style=\"text-align: center\"\u003e\n\n[![AUR](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://github.com/lWoHvYe/unicorn/blob/main/LICENSE)\n[![GitHub stars](https://img.shields.io/github/stars/lWoHvYe/unicorn.svg?style=social\u0026label=Stars)](https://github.com/lWoHvYe/unicorn)\n[![GitHub forks](https://img.shields.io/github/forks/lWoHvYe/unicorn.svg?style=social\u0026label=Fork)](https://github.com/lWoHvYe/unicorn)\n[![Dependency Review](https://github.com/lWoHvYe/unicorn/actions/workflows/dependency-review.yml/badge.svg)](https://github.com/lWoHvYe/unicorn/actions/workflows/dependency-review.yml)\n[![CodeQL](https://github.com/lWoHvYe/unicorn/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/lWoHvYe/unicorn/actions/workflows/codeql-analysis.yml)\n[![Gradle Package](https://github.com/lWoHvYe/unicorn/actions/workflows/gradle-publish.yml/badge.svg)](https://github.com/lWoHvYe/unicorn/actions/workflows/gradle-publish.yml)\n\u003c/div\u003e\n\n本项目在eladmin项目的基础上，进行了部分扩展及尝试，在此表示感谢。\n\n\n---\n\n启动类 [AppRun.java](https://github.com/lWoHvYe/unicorn-starter/tree/master/src/main/java/com/lwohvye/AppRun.java)\n和配置文件 [resources](https://github.com/lWoHvYe/unicorn-starter/tree/master/src/main/resources)\n详见 [unicorn-starter](https://github.com/lWoHvYe/unicorn-starter)\n模块。[启停脚本](script)。\n\n**Java16**之后，默认强封装JDK内部类，详见[JEP 396](https://openjdk.java.net/jeps/396)\n[JEP 403](https://openjdk.java.net/jeps/403)，需在启动时添加相关参数开启包访问。较简单的是添加\n``--add-opens java.base/java.lang=ALL-UNNAMED`` ，也可根据需要缩小范围（在Java 9引入的JPMS/Jigsaw）。\n详见：[Java 16](document/jdk/Java-16.md) [Java 17](document/jdk/Java-17.md)\n\n**Java 19**起，引入Virtual Threads/Project Loom，相关[详见](document/jdk/Java-Preview-loom.md)\n\n---\n\n#### 引用方式 🎵\n\n最新版本为: [![Maven Central](https://img.shields.io/maven-central/v/com.lwohvye/unicorn.svg?logo=github\u0026style=flat)](https://mvnrepository.com/artifact/com.lwohvye/unicorn)\n\n##### Maven\n\n```xml\n\n\u003cproject\u003e\n\n    \u003cproject.core.version\u003e4.6.0-upsilon\u003c/project.core.version\u003e\n\n    \u003c!--    system模块    --\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.lwohvye\u003c/groupId\u003e\n        \u003cartifactId\u003eunicorn-security\u003c/artifactId\u003e\n        \u003cversion\u003e${project.core.version}\u003c/version\u003e\n    \u003c/dependency\u003e\n    \u003c!--   logging模块     --\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.lwohvye\u003c/groupId\u003e\n        \u003cartifactId\u003eunicorn-logging\u003c/artifactId\u003e\n        \u003cversion\u003e${project.core.version}\u003c/version\u003e\n    \u003c/dependency\u003e\n\u003c/project\u003e\n\n```\n\n##### Gradle\n\n```groovy\n// 4.x系列基于Java 21, 部分module使用Kotlin, 使用Gradle build\next { // 这个定义是可以传递的\n    unicornVersion = '4.6.0-upsilon'\n}\n\nimplementation \"com.lwohvye:unicorn-security:$unicornVersion\"\n\n// 引入custom-bzLog\nimplementation(\"com.lwohvye:unicorn-security:$unicornVersion\") {\n    capabilities {\n        // 这里只支撑横线，不支持驼峰\n        requireCapability('com.lwohvye:unicorn-security-business-log')\n    }\n}\n```\n\n---\n\n#### 项目简介\n\n一个基于最新的Java 21(17) 版本、 Spring Boot 3.4、 Jpa、 Spring Security、RabbitMQ、Vue的前后端分离的脚手架。\n在各模块基本解耦之后，可根据需要只引入部分模块实现相关职能。\n\n#### 项目源码\n\n|            | 后端源码                               | 前端源码                                   |\n|------------|------------------------------------|----------------------------------------|\n| 原项目-github | https://github.com/elunez/eladmin  | https://github.com/elunez/eladmin-web  |\n| 原项目-码云     | https://gitee.com/elunez/eladmin   | https://gitee.com/elunez/eladmin-web   |\n| github     | https://github.com/lWoHvYe/unicorn | https://github.com/lWoHvYe/unicorn-web |\n\n#### 主要特性\n\n- 使用最新技术栈，社区资源丰富，基于Java 21(Core Module Support 17-21,24)、Spring Boot 3.4。\n  (Support Virtual Threads/fibre/loom)\n- 基于注解的动态查询（Specification），可根据需要扩充查询注解。\n- 支持接口级别的功能权限，动态权限控制\n- 支持数据字典，可方便地对一些状态进行管理\n- 高效率开发，代码生成器可一键生成前后端代码\n- 对一些常用前端组件封装：表格数据请求、数据字典等\n- 前后端统一异常拦截处理，统一输出异常，避免繁琐的判断\n- 使用ShardingSphere实现多数据源和读写分离。该方式针对MySQL数据库。对系统侵入性小。（只需引入依赖，并在yaml中配置数据源信息即可）\n  [unicorn-starter](https://github.com/lWoHvYe/unicorn-starter)。\n- 整合Redisson拓展Redis的功能，读写分离\n- 整合消息队列RabbitMQ，实现消息通知、延迟消息，服务解耦。\n- 各模块独立，基本可插拔：若只需查询注解等基础功能，只需引入Core模块即可，Beans, Security, Logging, 3rd Tools, Code Gen\n  模块可插拔， 除了传统To B业务，还可用于To C业务（see [OAuth2.0 part](unicorn-oauth2) ）\n\n#### 系统功能\n\n- 用户管理：提供用户的相关配置，新增用户后，默认密码为123456\n- 角色管理：对权限与菜单进行分配，菜单权限、接口权限(_In Progress_)\n- 菜单管理：已实现菜单动态路由，后端可配置化，支持多级菜单\n- 部门管理：可配置系统组织架构，树形表格展示(Draft)\n- 岗位管理：配置各个部门的职位(Draft)\n- 字典管理：可维护常用一些固定的数据，如：状态，性别等\n- 系统日志：记录用户操作日志与异常日志，方便开发人员定位排错\n- 定时任务：整合Quartz做定时任务，加入任务日志，任务运行情况一目了然\n- 代码生成：高灵活度生成前后端代码，减少大量重复的工作任务（逆向有很多方案，这种基于template的有一定的灵活性）\n- 邮件工具：配合富文本，发送html格式的邮件\n\n#### 项目结构\n\n项目采用按功能分模块的开发方式，结构如下\n\n- `unicorn-core` 系统的Core模块，BaseClass及各种Util，(基于Multi-Release JAR Files，Support Java 17 - 21), \n  baseline 为Java 17, 在Runtime = 17 时使用传统threadPool，在Runtime \u003e= 21时使用Virtual Threads\n\n- `unicorn-beans` 基础Beans的Definition及Configuration，To C业务可只引入该dependency\n\n- `unicorn-sys-api` Sys Module基础实体及API，方便服务拆分\n\n- `unicorn-security` 系统权限模块，包含权限配置管理等。\n\n- `unicorn-logging` 系统的日志模块，其他模块如果需要记录日志需要引入该模块，亦可自行实现\n\n- `unicorn-tp-tools-kotlin` 第三方工具模块，包含：邮件、S3，可视情况引入\n\n- `unicorn-code-gen-kotlin` 系统的代码生成模块。这部分待优化，亦非必须模块\n\n- `unicorn-starter` [启动类(Maven)，项目入口，包含模块及组件配置（DB读写分离 + Cache读写分离）](https://github.com/lWoHvYe/unicorn-starter)\n\n- `valentine-starter` 启动配置示例(Gradle)，尝试Kotlin/Kotlinx\n\n- `unicorn-oauth2` OAuth2 Sample，AuthorizationServer, OAuth2Client + Gateway, ResourceServer(Web MVC \u0026 WebFlux)\n\n#### 详细结构\n\n```\n- unicorn-core 公共模块(Baseline Java 17)\n    - annotation 为系统自定义注解\n    - base 提供了Entity、Service、DTO基类和mapstruct的通用mapper\n    - exception 项目自定义异常类\n    - utils 系统通用工具类, security, json, rabbitmq, redis,...\n        - QueryHelp 基于Annotation的JPA动态查询Specification\n        - SpringContextHolder 自定义SpringUtil\n        - JDKUtils, UnsafeUtils\n        - XRabbitAbstractProducer, YRabbitAbstractConsumer\n        - SecurityUtils, ReactiveSecurityUtils\n    - java21/utils Virtual Threads for Java Runtime 21+ (Multi-Release Jar)\n- unicorn-beans 基础Bean\n    - advice 统一数据返回及异常处理\n    - config 基础配置，Security配置，redis配置，openApi配置，Rsa配置等\n        - security 权限控制，为swarm化，提供全局关闭Security功能\n        - UnicornAutoConfiguration: 自动化装配\n        - ValentineExecutorConfig: Running Spring Applications (Servlet Web Servers \u0026 Task Execution) on Virtual Threads Before Spring Boot 3.2\n- unicorn-sys-api 基础实体及DTO\n    - modules 基础实体及接口定义\n- unicorn-security 系统核心模块\n\t- common 配置跨域、静态资源、数据权限、实体表映射、系统完成入口\n\t    - config \n\t    - init 容器启动后的钩子call back\n\t    - orm jpa-entity的部分配置，eg: Table Mapping\n\t    - web corsFilter configurer and so on\n\t- modules 系统相关模块(登录授权、消息队列、系统监控、定时任务、运维管理等)\n\t    - infrastructure business log相关\n\t    - mnt.websocket WebSocket\n\t    - quartz 定时任务\n\t    - rabbitmq 消息队列相关\n\t    - security 核心权限控制\n\t    - system 用户-权限管理\n- unicorn-logging 系统日志模块\n    - aspect 基于Anno的log切面\n    - rabbitmq Async log\n- unicorn-tp-tools-kotlin 系统第三方工具模块(kotlin)\n- unicorn-code-gen-kotlin 系统代码生成模块(kotlin)\n```\n\n#### 运行环境\n\n- Java 21 基础运行环境\n- Mysql 5.7/8.0 数据库 读写分离/单数据源-通过配置数据源的方式切换\n- Redis 7.2 缓存\n- RabbitMQ 发布-订阅（解耦、异步）\n- ELK 日志系统，config for prod env\n- 可基于docker [一键搭建](document/docker/docker-compose-env.yml)。当然目录还是要自己建的，另外RabbitMQ记得装延迟插件，ES记得装IK\n- 若想搭建k8s版，可[参照](https://github.com/lWoHvYe/mall-swarm/tree/main/document/kubernetes/env) ,这个是基于NFS挂载的。\n\n#### 特别鸣谢\n\n- 感谢 [PanJiaChen](https://github.com/PanJiaChen/vue-element-admin) 大佬提供的前端模板\n\n- 感谢 [Moxun](https://github.com/moxun1639) 大佬提供的前端 Curd 通用组件\n\n- 感谢 [zhy6599](https://gitee.com/zhy6599) 大佬提供的后端运维管理相关功能\n\n- 感谢 [j.yao.SUSE](https://github.com/everhopingandwaiting) 大佬提供的匿名接口与Redis限流等功能\n\n- 感谢 [d15801543974](https://github.com/d15801543974) 大佬提供的基于注解的通用查询方式\n\n- 感谢 [elunez](https://github.com/elunez) 大佬提供的eladmin项目\n\n---\n\n#### Feature list\n\n- dev_4.0 JPMS改造（3.0版本有做部分尝试，当前在IDEA中可开发调试，但模块化打包部署尚未以Named Module的方式运行，\n  推测是Spring Boot的 ClassLoader下全是Auto-Module）\n- Resource管理页面(partly，角色-资源管理)，delay\n- swarm化，可以参考[why-swarm (已停工，计划重构 toC + OAuth2.0)](https://github.com/WHY-lWoHvYe/why-swarm)\n\n#### TODO\n\n- OAuth 2.0 (_In Progress_)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flwohvye%2Funicorn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flwohvye%2Funicorn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flwohvye%2Funicorn/lists"}