GithubHelp home page GithubHelp logo

lwohvye / unicorn Goto Github PK

View Code? Open in Web Editor NEW
32.0 5.0 20.0 21.24 MB

基于最新的Java 21和SpringBoot 3.2。根据eladmin项目进行改造。整合常用的Components.

Home Page: https://lwohvye.github.io/unicorn/

License: Apache License 2.0

Java 80.86% FreeMarker 2.34% PLpgSQL 4.84% Shell 0.27% Kotlin 10.76% HTML 0.93%
jpa java spring-boot spring-security unicorn lwohvye gradle kotlin websocket oauth2

unicorn's Introduction

Chaste Unicorn Unicorn

AUR GitHub stars GitHub forks Dependency Review CodeQL Gradle Package Qodana

本项目在eladmin项目的基础上,进行了部分扩展及尝试,在此表示感谢。

For lWoHvYe/unicorn project, will stay at Java 21 until 2025. will try Java 21+ in WHY-lWoHvYe/valentine-p2p (skip Java 22)


启动类 AppRun.java 和配置文件 resources 详见 unicorn-starter 模块。启停脚本

Java16之后,默认强封装JDK内部类,详见JEP 396 JEP 403,需在启动时添加相关参数开启包访问。较简单的是添加 --add-opens java.base/java.lang=ALL-UNNAMED ,也可根据需要缩小范围(在Java 9引入的JPMS/Jigsaw)。 详见:Java 16 Java 17

Java 19起,引入Virtual Threads/Project Loom,相关详见


引用方式 🎵

最新版本为: Maven Central

Maven
<project>

    <project.core.version>4.3.0-rho</project.core.version>

    <!--    system模块    -->
    <dependency>
        <groupId>com.lwohvye</groupId>
        <artifactId>unicorn-security</artifactId>
        <version>${project.core.version}</version>
    </dependency>
    <!--   logging模块     -->
    <dependency>
        <groupId>com.lwohvye</groupId>
        <artifactId>unicorn-logging</artifactId>
        <version>${project.core.version}</version>
    </dependency>
</project>
Gradle
// 4.x系列将基于Java 21, 部分module使用Kotlin, 使用Gradle build
ext { // 这个定义是可以传递的
    unicornVersion = '4.3.0-rho'
}

implementation "com.lwohvye:unicorn-security:$unicornVersion"

// 引入滑动captcha
implementation("com.lwohvye:unicorn-security:$unicornVersion") {
    capabilities {
        requireCapability('com.lwohvye:unicorn-security-captcha')
    }
}
// 引入custom-log
implementation("com.lwohvye:unicorn-security:$unicornVersion") {
    capabilities {
        // 这里只支撑横线,不支持驼峰
        requireCapability('com.lwohvye:unicorn-security-business-log')
    }
}

项目简介

一个基于最新的Java 21(17) 版本、 Spring Boot 3.2、 Jpa、 Spring Security、RabbitMQ、Vue的前后端分离的脚手架。 在各模块基本解耦之后,可根据需要只引入部分模块实现相关职能。

项目源码

后端源码 前端源码
原项目-github https://github.com/elunez/eladmin https://github.com/elunez/eladmin-web
原项目-码云 https://gitee.com/elunez/eladmin https://gitee.com/elunez/eladmin-web
github https://github.com/lWoHvYe/unicorn https://github.com/lWoHvYe/unicorn-web

主要特性

  • 使用最新技术栈,社区资源丰富,基于Java 21(Core Module Support 17-21)、Spring Boot 3.2。 (Support Virtual Threads/fibre/loom)
  • 基于注解的动态查询(Specification),可根据需要扩充查询注解。
  • 支持接口级别的功能权限,动态权限控制
  • 支持数据字典,可方便地对一些状态进行管理
  • 高效率开发,代码生成器可一键生成前后端代码
  • 对一些常用前端组件封装:表格数据请求、数据字典等
  • 前后端统一异常拦截处理,统一输出异常,避免繁琐的判断
  • 使用ShardingSphere实现多数据源和读写分离。该方式针对MySQL数据库。对系统侵入性小。(只需引入依赖,并在yaml中配置数据源信息即可) unicorn-starter
  • 整合Redisson拓展Redis的功能,读写分离
  • 整合消息队列RabbitMQ,实现消息通知、延迟消息,服务解耦。
  • 各模块独立,基本可插拔:若只需查询注解等基础功能,只需引入Core模块即可,Beans, Security, Logging, 3rd Tools, Code Gen 模块可插拔, 除了传统To B业务,还可用于To C业务(see OAuth2.0 part

系统功能

  • 用户管理:提供用户的相关配置,新增用户后,默认密码为123456
  • 角色管理:对权限与菜单进行分配,菜单权限、数据权限(Draft)、接口权限(In Progress)
  • 菜单管理:已实现菜单动态路由,后端可配置化,支持多级菜单
  • 部门管理:可配置系统组织架构,树形表格展示(Draft)
  • 岗位管理:配置各个部门的职位(Draft)
  • 字典管理:可维护常用一些固定的数据,如:状态,性别等
  • 系统日志:记录用户操作日志与异常日志,方便开发人员定位排错
  • 定时任务:整合Quartz做定时任务,加入任务日志,任务运行情况一目了然
  • 代码生成:高灵活度生成前后端代码,减少大量重复的工作任务(逆向有很多方案,这种基于template的有一定的灵活性)
  • 邮件工具:配合富文本,发送html格式的邮件

项目结构

项目采用按功能分模块的开发方式,结构如下

  • unicorn-core 系统的Core模块,BaseClass及各种Util,(基于Multi-Release JAR Files,Support Java 17 - 21)

  • unicorn-beans 基础Beans的Definition及Configuration,To C业务可只引入该dependency

  • unicorn-sys-api Sys Module基础实体及API,方便服务拆分

  • unicorn-security 系统权限模块,包含权限配置管理等。

  • unicorn-logging 系统的日志模块,其他模块如果需要记录日志需要引入该模块,亦可自行实现

  • unicorn-tp-tools-kotlin 第三方工具模块,包含:邮件、S3,可视情况引入

  • unicorn-code-gen-kotlin 系统的代码生成模块。这部分待优化,亦非必须模块

  • unicorn-starter 启动类(Maven),项目入口,包含模块及组件配置(DB读写分离 + Cache读写分离)

  • valentine-starter 启动配置示例(Gradle),尝试Kotlin/Kotlinx

  • unicorn-oauth2 OAuth2 Sample,AuthorizationServer, OAuth2Client + Gateway, ResourceServer

详细结构

- unicorn-core 公共模块
    - annotation 为系统自定义注解
    - base 提供了Entity、Service、DTO基类和mapstruct的通用mapper
    - exception 项目自定义异常类
    - utils 系统通用工具类, security, json, rabbitmq, redis,...
        - QueryHelp 基于Annotation的JPA动态查询Specification
        - SpringContextHolder 自定义SpringUtil
        - JDKUtils, UnsafeUtils
        - XRabbitAbstractProducer, YRabbitAbstractConsumer
        - SecurityUtils, ReactiveSecurityUtils
- unicorn-beans 基础Bean
    - advice 统一数据返回及异常处理
    - config 基础配置,Security配置,redis配置,openApi配置,Rsa配置等
        - security 权限控制,为swarm化,提供全局关闭Security功能
        - UnicornAutoConfiguration: 自动化装配
        - ValentineExecutorConfig: Running Spring Applications (Servlet Web Servers & Task Execution) on Virtual Threads Before Spring Boot 3.2
- unicorn-sys-api 基础实体及DTO
    - modules 基础实体及接口定义
- unicorn-security 系统核心模块
	- common 配置跨域、静态资源、数据权限、实体表映射、系统完成入口
	    - config 
	    - init 容器启动后的钩子call back
	    - orm jpa-entity的部分配置,eg: Table Mapping
	    - web corsFilter configurer and so on
	- modules 系统相关模块(登录授权、消息队列、系统监控、定时任务、运维管理等)
	    - infrastructure business log相关
	    - mnt.websocket WebSocket
	    - quartz 定时任务
	    - rabbitmq 消息队列相关
	    - security 核心权限控制
	    - system 用户-权限管理
- unicorn-logging 系统日志模块
    - aspect 基于Anno的log切面
    - rabbitmq Async log
- unicorn-tp-tools-kotlin 系统第三方工具模块(kotlin)
- unicorn-code-gen-kotlin 系统代码生成模块(kotlin)

运行环境

  • Java 21 基础运行环境
  • Mysql 5.7/8.0 数据库 读写分离/单数据源-通过配置数据源的方式切换
  • Redis 7.2 缓存
  • RabbitMQ 发布-订阅(解耦、异步)
  • ELK 日志系统,config for prod env
  • 可基于docker 一键搭建。当然目录还是要自己建的,另外RabbitMQ记得装延迟插件,ES记得装IK
  • 若想搭建k8s版,可参照 ,这个是基于NFS挂载的。

特别鸣谢

  • JetBrains Logo (Main) logo

  • 感谢 JetBrains 提供的非商业开源软件开发授权。

  • 感谢 PanJiaChen 大佬提供的前端模板

  • 感谢 Moxun 大佬提供的前端 Curd 通用组件

  • 感谢 zhy6599 大佬提供的后端运维管理相关功能

  • 感谢 j.yao.SUSE 大佬提供的匿名接口与Redis限流等功能

  • 感谢 d15801543974 大佬提供的基于注解的通用查询方式

  • 感谢 elunez 大佬提供的eladmin项目


Feature list

  • dev_4.0 JPMS改造(3.0版本有做部分尝试,当前在IDEA中可开发调试,但模块化打包部署尚未以Named Module的方式运行, 推测是Spring Boot的 ClassLoader下全是Auto-Module)
  • Resource管理页面(partly,角色-资源管理),delay
  • swarm化,可以参考why-swarm (已停工,计划重构 toC + OAuth2.0)

TODO

  • OAuth 2.0 (In Progress)

unicorn's People

Contributors

1797890817 avatar cnzbq avatar d15801543974 avatar dependabot[bot] avatar edinjohn avatar elunez avatar erichetti avatar everhopingandwaiting avatar github-actions[bot] avatar imjyz avatar jhpx avatar jiabing0 avatar jiefei30 avatar jinlongliao avatar lihengcn avatar linlihuiyang avatar lj-zhu avatar lwohvye avatar pleaseyang avatar shanezhiu avatar tsln1998 avatar wencygit avatar wtune avatar yangzongzhuan avatar yuankangli avatar yuchumian avatar yuyu1025 avatar zanjs avatar zhy6599 avatar zoulejiu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

unicorn's Issues

OAuth2.0

valentine 进行。从开始到初步完成预计要很长时间

项目结构等预期会有所较大调整,后续会独立于此Project
OAuth2

启动编译报错

你好,我本地java环境是21,把代码拉下来后,编译报错:
Your build is currently configured to use Java 21 and Gradle 8.5.

Possible solution:

  • Use Java 20 as Gradle JVM: Open Gradle settings
  • Open Gradle wrapper settings, change distributionUrl property to use compatible Gradle version and reload the project
    我在网上找了很久,都没得到解决,找chatgpt,也是说让我确认我本地是否是java21,gradle是否是8.5.为此我还下载了一个gradle也还是没有解决

JPMS改造

Java 9引入了Java平台模块系统。计划对项目进行相关改造

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.