Skip to content

Commit

Permalink
Merge pull request #292 from WHY-lWoHvYe/main
Browse files Browse the repository at this point in the history
Java 21 with Virtual Threads
  • Loading branch information
lWoHvYe committed Sep 21, 2023
2 parents f672211 + 2f53752 commit e5fca84
Show file tree
Hide file tree
Showing 182 changed files with 874 additions and 6,483 deletions.
13 changes: 5 additions & 8 deletions .github/workflows/codeql-analysis.yml
Expand Up @@ -22,7 +22,6 @@ on:

jobs:
analyze:
name: Analyze
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
Expand All @@ -34,11 +33,13 @@ jobs:
fail-fast: false
matrix:
language: [ 'java' ]
distribution: [ 'zulu', 'temurin', 'oracle' ]
java: [ '21' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

name: Analyze Java ${{ matrix.Java }} (${{ matrix.distribution }}) Build
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -47,9 +48,9 @@ jobs:
uses: actions/setup-java@v3
with:
# The Java version to set up. Takes a whole or semver Java version. See examples of supported syntax in README file
java-version: '20'
java-version: ${{ matrix.java }}
# Java distribution. See the list of supported distributions in README file
distribution: 'oracle'
distribution: ${{ matrix.distribution }}
# The package type (jdk, jre, jdk+fx, jre+fx)
#java-package: # optional, default is jdk
# The architecture of the package
Expand Down Expand Up @@ -107,10 +108,6 @@ jobs:
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
- name: Publish 2 MavenLocal
uses: gradle/gradle-build-action@v2
with:
arguments: publishToMavenLocal

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/docker-image.yml
Expand Up @@ -25,8 +25,8 @@ jobs:
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
java-version: '20'
distribution: 'temurin'
java-version: '21'
distribution: 'oracle'
check-latest: true
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
Expand All @@ -46,9 +46,3 @@ jobs:
uses: gradle/gradle-build-action@v2
with:
arguments: publishToMavenLocal

- name: Remove module-info
run: rm -rf unicorn-starter/src/main/java/module-info.java

- name: Build Unicorn-Starter
run: mvn -B package --file unicorn-starter/pom.xml -P jigsaw
39 changes: 39 additions & 0 deletions .github/workflows/graalvm_macos.yml
@@ -0,0 +1,39 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:
runs-on: macos-latest

steps:
- uses: actions/checkout@v4
# https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Installing-custom-Java-package-type
- name: Download JDK
run: |
download_url="https://download.oracle.com/graalvm/21/latest/graalvm-jdk-21_macos-x64_bin.tar.gz"
wget -O $RUNNER_TEMP/java_package.tar.gz $download_url
- uses: actions/setup-java@v3
with:
distribution: 'jdkfile'
jdkFile: ${{ runner.temp }}/java_package.tar.gz
java-version: '21'
architecture: x64
- name: Build with Gradle
uses: gradle/gradle-build-action@v2 # v2.6.0
with:
arguments: classes publishToMavenLocal
4 changes: 2 additions & 2 deletions .github/workflows/gradle-publish.yml
Expand Up @@ -21,10 +21,10 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up JDK 20
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '20'
java-version: '21'
distribution: 'zulu'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
Expand Down
28 changes: 0 additions & 28 deletions .idea/encodings.xml

This file was deleted.

15 changes: 0 additions & 15 deletions .idea/git_toolbox_prj.xml

This file was deleted.

5 changes: 1 addition & 4 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/UnicornAppRun.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions .idea/sqldialects.xml

This file was deleted.

4 changes: 2 additions & 2 deletions .space.kts
Expand Up @@ -5,7 +5,7 @@
*/

job("Assemble & BuildImage") {
container(displayName = "Run gradle build", image = "eclipse-temurin:20-alpine") {
container(displayName = "Run gradle build", image = "eclipse-temurin:21-alpine") {

kotlinScript { api ->
// here can be your complex logic
Expand All @@ -14,7 +14,7 @@ job("Assemble & BuildImage") {
}
}

container(displayName = "Run gradle build", image = "amazoncorretto:20-alpine") {
container(displayName = "Run gradle build", image = "amazoncorretto:21-alpine") {

kotlinScript { api ->
// here can be your complex logic
Expand Down
65 changes: 32 additions & 33 deletions README.md
Expand Up @@ -25,6 +25,8 @@
``--add-opens java.base/java.lang=ALL-UNNAMED`` ,也可根据需要缩小范围(在Java 9引入的JPMS/Jigsaw)。
详见:[Java 16](document/jdk/Java-16.md) [Java 17](document/jdk/Java-17.md)

**Java 19**起,引入Virtual Threads/Project Loom,相关[详见](document/jdk/Java-Preview.md)

---

#### 引用方式 🎵
Expand All @@ -33,27 +35,25 @@

##### Maven

**可根据需要选择版本**

```xml
<!--2.6.18版本为springfox + 未进行动态权限改造-->
<!-- https://mvnrepository.com/artifact/com.lwohvye/eladmin -->
<dependency>
<groupId>com.lwohvye</groupId>
<artifactId>eladmin</artifactId>
<version>2.6.18</version>
<type>pom</type>
</dependency>
```

```xml
<!--3.x系列版本为springdoc + 动态权限改造 + JPMS部分改造-->
<dependency>
<groupId>com.lwohvye</groupId>
<artifactId>unicorn</artifactId>
<version>3.2.0</version>
<type>pom</type>
</dependency>
<project>

<project.core.version>4.2.0-pi</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>

```

Expand All @@ -62,7 +62,7 @@
```groovy
// 4.x系列将基于Java 21, 部分module使用Kotlin, 使用Gradle build
ext { // 这个定义是可以传递的
unicornVersion = '4.0.1-lambda'
unicornVersion = '4.2.0-pi'
}
implementation "com.lwohvye:unicorn-security:$unicornVersion"
Expand All @@ -86,7 +86,7 @@ implementation("com.lwohvye:unicorn-security:$unicornVersion") {

#### 项目简介

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

#### 项目源码
Expand All @@ -99,15 +99,14 @@ implementation("com.lwohvye:unicorn-security:$unicornVersion") {

#### 主要特性

- 使用最新技术栈,社区资源丰富,基于Java 20、Spring Boot 3.1。(Support Virtual Threads/loom)
- 使用最新技术栈,社区资源丰富,基于Java 21、Spring Boot 3.2。(Support Virtual Threads/fibre/loom)
- 基于注解的动态查询(Specification),可根据需要扩充查询注解。
- 支持接口级别的功能权限,动态权限控制
- 支持数据字典,可方便地对一些状态进行管理
- 高效率开发,代码生成器可一键生成前后端代码
- 对一些常用前端组件封装:表格数据请求、数据字典等
- 前后端统一异常拦截处理,统一输出异常,避免繁琐的判断
- 使用ShardingSphere实现多数据源和读写分离。该方式针对MySQL数据库。对系统侵入性小。(只需引入依赖,并在yaml中配置数据源信息即可)。
- 另有TiDB分布式关系型数据库 方案,优于自行分库分表,但为Commercial方案,所以还是更推荐ShardingSphere。
- 整合Redisson拓展Redis的功能,读写分离
- 整合消息队列RabbitMQ,实现消息通知、延迟消息,服务解耦。
- 各模块独立,基本可插拔:若只需查询注解类基础功能,只需引入core模块即可,权限、日志、3rd Tools模块可插拔可独立部署,
Expand All @@ -116,7 +115,7 @@ implementation("com.lwohvye:unicorn-security:$unicornVersion") {
#### 系统功能

- 用户管理:提供用户的相关配置,新增用户后,默认密码为123456
- 角色管理:对权限与菜单进行分配,菜单权限、数据权限、接口权限(TODO)
- 角色管理:对权限与菜单进行分配,菜单权限、数据权限(Draft)、接口权限(_In Progress_)
- 菜单管理:已实现菜单动态路由,后端可配置化,支持多级菜单
- 部门管理:可配置系统组织架构,树形表格展示(Draft)
- 岗位管理:配置各个部门的职位(Draft)
Expand All @@ -136,15 +135,15 @@ implementation("com.lwohvye:unicorn-security:$unicornVersion") {

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

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

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

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

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

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

#### 详细结构

Expand All @@ -156,7 +155,7 @@ implementation("com.lwohvye:unicorn-security:$unicornVersion") {
- config 基础配置,Security配置,redis配置,openApi配置,Rsa配置等
- security 权限控制,为swarm化,提供全局关闭Security功能
- UnicornAutoConfiguration: 自动化装配
- ValentineExecutorConfig: Running Spring Applications on Virtual Threads
- ValentineExecutorConfig: Running Spring Applications (Servlet Web Servers & Task Execution) on Virtual Threads Before Spring Boot 3.2
- exception 项目自定义异常类
- utils 系统通用工具类, json, rabbitmq, redis,...
- QueryHelp 基于Annotation的JPA动态查询Specification
Expand All @@ -183,13 +182,13 @@ implementation("com.lwohvye:unicorn-security:$unicornVersion") {
- rabbitmq Async log
- unicorn-tp-tools 系统第三方工具模块(kotlin)
- unicorn-code-gen 系统代码生成模块(kotlin)
- loom-20-ext 在Java 20使用SpringBoot 并Enable其对VT的Support的兼容包
```

#### 运行环境

- Java 20 基础运行环境
- Java 21 基础运行环境
- Mysql 5.7/8.0 数据库 读写分离/单数据源-通过配置数据源的方式切换
- 拓展使用分布式关系型数据库 [TiDB](https://docs.pingcap.com/zh/tidb/stable)
- Redis 6.0 缓存
- RabbitMQ 发布-订阅(解耦、异步)
- ELK 日志系统,config for prod env
Expand Down Expand Up @@ -218,12 +217,12 @@ implementation("com.lwohvye:unicorn-security:$unicornVersion") {

#### Feature list

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

#### TODO

- OAuth 2.0 (_In Progress_)
- Loom + Kotlin Coroutines
- Loom + Kotlin Coroutines (_In Progress_)
6 changes: 3 additions & 3 deletions SECURITY.md
Expand Up @@ -7,9 +7,9 @@ currently being supported with security updates.

| Version | Supported |
| ------- | ------------------ |
| 3.0.x | :white_check_mark: |
| 2.6.18 ||
| < 2.6.18 ||
| 4.x | :white_check_mark: |
| 3.x ||
| 2.x ||

## Reporting a Vulnerability

Expand Down

0 comments on commit e5fca84

Please sign in to comment.