From 1c9c2964131f58b46cfc403bdc7a4ef828698301 Mon Sep 17 00:00:00 2001 From: Arthur Ming Date: Tue, 6 Jun 2023 10:24:11 +0800 Subject: [PATCH 1/7] feat: bump spring boot to v3.0.0 --- build.gradle | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index f5bdd58..48f0e56 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'org.springframework.boot' version '2.7.12' + id 'org.springframework.boot' version '3.0.0' id 'io.spring.dependency-management' version '1.1.0' id 'org.flywaydb.flyway' version '9.19.1' id 'java' @@ -27,7 +27,7 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-quartz' implementation 'org.springframework.boot:spring-boot-starter-aop' implementation 'io.springfox:springfox-boot-starter:3.0.0' - implementation 'org.apache.shiro:shiro-spring-boot-starter:1.9.1' + implementation 'org.apache.shiro:shiro-spring-boot-starter:1.11.0' implementation 'com.auth0:java-jwt:3.19.4' implementation 'org.postgresql:postgresql' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ae04661..fae0804 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 6253f7b..a69d9cb 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From 5a1cd6d79923b6d562791dd54f55a0392bc95263 Mon Sep 17 00:00:00 2001 From: Arthur Ming Date: Tue, 6 Jun 2023 11:19:59 +0800 Subject: [PATCH 2/7] fix: bug fix --- WORKSPACE | 15 ++++++++------- build.gradle | 3 ++- .../api/interceptor/ControllerInterceptor.java | 2 +- .../org/daming/jobs/base/shiro/JWTFilter.java | 8 ++++---- .../daming/jobs/base/shiro/ShiroUserService.java | 2 +- .../org/daming/jobs/base/utils/CommonUtils.java | 3 ++- .../java/org/daming/jobs/config/ShiroConfig.java | 4 ++-- 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 41e8e40..c8ac96e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -26,18 +26,19 @@ load("@rules_jvm_external//:defs.bzl", "maven_install") maven_install( artifacts = [ - "org.springframework.boot:spring-boot-starter-web:2.7.12", - "org.springframework.boot:spring-boot-starter-jdbc:2.7.12", - "org.springframework.boot:spring-boot-starter-quartz:2.7.12", - "org.springframework.boot:spring-boot-starter-aop:2.7.12", + "org.springframework.boot:spring-boot-starter-web:3.0.0", + "org.springframework.boot:spring-boot-starter-jdbc:3.0.0", + "org.springframework.boot:spring-boot-starter-quartz:3.0.0", + "org.springframework.boot:spring-boot-starter-aop:3.0.0", "io.springfox:springfox-boot-starter:3.0.0", - "org.apache.shiro:shiro-spring-boot-starter:1.9.1", + "org.apache.shiro:shiro-spring-boot-starter:2.0.0-alpha-2", + "org.apache.shiro:shiro-jakarta-ee:2.0.0-alpha-2", "com.auth0:java-jwt:3.19.4", "org.postgresql:postgresql:42.4.0", - "org.springframework.boot:spring-boot-devtools:2.7.12", - "org.springframework.boot:spring-boot-starter-test:2.7.12" + "org.springframework.boot:spring-boot-devtools:3.0.0", + "org.springframework.boot:spring-boot-starter-test:3.0.0" ], fetch_sources = True, diff --git a/build.gradle b/build.gradle index 48f0e56..99d8946 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,8 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-quartz' implementation 'org.springframework.boot:spring-boot-starter-aop' implementation 'io.springfox:springfox-boot-starter:3.0.0' - implementation 'org.apache.shiro:shiro-spring-boot-starter:1.11.0' + implementation 'org.apache.shiro:shiro-spring-boot-starter:2.0.0-alpha-2' + implementation 'org.apache.shiro:shiro-jakarta-ee:2.0.0-alpha-2' implementation 'com.auth0:java-jwt:3.19.4' implementation 'org.postgresql:postgresql' diff --git a/src/main/java/org/daming/jobs/api/interceptor/ControllerInterceptor.java b/src/main/java/org/daming/jobs/api/interceptor/ControllerInterceptor.java index 7b78b03..f8aa3b0 100644 --- a/src/main/java/org/daming/jobs/api/interceptor/ControllerInterceptor.java +++ b/src/main/java/org/daming/jobs/api/interceptor/ControllerInterceptor.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.servlet.http.HttpServletRequest; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; @@ -14,7 +15,6 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import javax.servlet.http.HttpServletRequest; import java.util.UUID; /** diff --git a/src/main/java/org/daming/jobs/base/shiro/JWTFilter.java b/src/main/java/org/daming/jobs/base/shiro/JWTFilter.java index a80bfef..a207cb3 100644 --- a/src/main/java/org/daming/jobs/base/shiro/JWTFilter.java +++ b/src/main/java/org/daming/jobs/base/shiro/JWTFilter.java @@ -1,15 +1,15 @@ package org.daming.jobs.base.shiro; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter; import org.daming.jobs.base.logger.DamingLogger; import org.daming.jobs.base.logger.LoggerManager; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.RequestMethod; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import java.io.IOException; diff --git a/src/main/java/org/daming/jobs/base/shiro/ShiroUserService.java b/src/main/java/org/daming/jobs/base/shiro/ShiroUserService.java index 4e7e5cc..8932f70 100644 --- a/src/main/java/org/daming/jobs/base/shiro/ShiroUserService.java +++ b/src/main/java/org/daming/jobs/base/shiro/ShiroUserService.java @@ -1,8 +1,8 @@ package org.daming.jobs.base.shiro; +import jakarta.annotation.PostConstruct; import org.springframework.stereotype.Service; -import javax.annotation.PostConstruct; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/org/daming/jobs/base/utils/CommonUtils.java b/src/main/java/org/daming/jobs/base/utils/CommonUtils.java index d271b14..b477eb9 100644 --- a/src/main/java/org/daming/jobs/base/utils/CommonUtils.java +++ b/src/main/java/org/daming/jobs/base/utils/CommonUtils.java @@ -1,6 +1,7 @@ package org.daming.jobs.base.utils; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; + import java.net.InetAddress; import java.net.UnknownHostException; import java.util.*; diff --git a/src/main/java/org/daming/jobs/config/ShiroConfig.java b/src/main/java/org/daming/jobs/config/ShiroConfig.java index c4b167d..41da766 100644 --- a/src/main/java/org/daming/jobs/config/ShiroConfig.java +++ b/src/main/java/org/daming/jobs/config/ShiroConfig.java @@ -1,5 +1,6 @@ package org.daming.jobs.config; +import jakarta.servlet.Filter; import org.apache.shiro.mgt.DefaultSessionStorageEvaluator; import org.apache.shiro.mgt.DefaultSubjectDAO; import org.apache.shiro.spring.LifecycleBeanPostProcessor; @@ -13,7 +14,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.DependsOn; -import javax.servlet.Filter; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; @@ -45,7 +45,7 @@ public ShiroFilterFactoryBean factory(DefaultWebSecurityManager securityManager) ShiroFilterFactoryBean factoryBean = new ShiroFilterFactoryBean(); // 添加自己的过滤器并且取名为jwt - Map filterMap = new HashMap<>(1); + Map filterMap = new HashMap<>(1); filterMap.put("jwt", new JWTFilter()); factoryBean.setFilters(filterMap); From f1bb66bf3f8be1231ae6bb3bbead4de0dce06d00 Mon Sep 17 00:00:00 2001 From: Arthur Ming Date: Tue, 6 Jun 2023 14:36:40 +0800 Subject: [PATCH 3/7] fix: update fix --- src/main/java/org/daming/jobs/config/ShiroConfig.java | 2 +- .../daming/jobs/config/service/impl/ErrorCodeServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/daming/jobs/config/ShiroConfig.java b/src/main/java/org/daming/jobs/config/ShiroConfig.java index 41da766..1e51764 100644 --- a/src/main/java/org/daming/jobs/config/ShiroConfig.java +++ b/src/main/java/org/daming/jobs/config/ShiroConfig.java @@ -45,7 +45,7 @@ public ShiroFilterFactoryBean factory(DefaultWebSecurityManager securityManager) ShiroFilterFactoryBean factoryBean = new ShiroFilterFactoryBean(); // 添加自己的过滤器并且取名为jwt - Map filterMap = new HashMap<>(1); + Map filterMap = new HashMap<>(1); filterMap.put("jwt", new JWTFilter()); factoryBean.setFilters(filterMap); diff --git a/src/main/java/org/daming/jobs/config/service/impl/ErrorCodeServiceImpl.java b/src/main/java/org/daming/jobs/config/service/impl/ErrorCodeServiceImpl.java index 3663b3f..6a8759c 100644 --- a/src/main/java/org/daming/jobs/config/service/impl/ErrorCodeServiceImpl.java +++ b/src/main/java/org/daming/jobs/config/service/impl/ErrorCodeServiceImpl.java @@ -5,7 +5,7 @@ import org.daming.jobs.pojo.ApiError; import org.springframework.stereotype.Service; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import java.util.HashMap; import java.util.Map; import java.util.Objects; From 7716b27fdd9d84e4a93476c6a4aa7c0e97a2f1b4 Mon Sep 17 00:00:00 2001 From: Arthur Ming Date: Mon, 7 Aug 2023 18:53:42 +0800 Subject: [PATCH 4/7] fix: fix all error --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 99d8946..9f38a62 100644 --- a/build.gradle +++ b/build.gradle @@ -27,8 +27,8 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-quartz' implementation 'org.springframework.boot:spring-boot-starter-aop' implementation 'io.springfox:springfox-boot-starter:3.0.0' - implementation 'org.apache.shiro:shiro-spring-boot-starter:2.0.0-alpha-2' - implementation 'org.apache.shiro:shiro-jakarta-ee:2.0.0-alpha-2' + implementation('org.apache.shiro:shiro-spring:1.11.0:jakarta') { exclude group: 'org.apache.shiro', module: 'shiro-web' } + implementation 'org.apache.shiro:shiro-web:1.11.0:jakarta' implementation 'com.auth0:java-jwt:3.19.4' implementation 'org.postgresql:postgresql' From 0668886a0683ed10c1eb8650a1d4a128573ec204 Mon Sep 17 00:00:00 2001 From: Arthur Ming Date: Tue, 8 Aug 2023 20:29:47 +0800 Subject: [PATCH 5/7] fix: update bazel --- .bazelrc | 6 +++++- .bazelrc.back | 2 -- .gitignore | 3 ++- WORKSPACE | 4 ++-- build.gradle | 4 ++-- 5 files changed, 11 insertions(+), 8 deletions(-) delete mode 100644 .bazelrc.back diff --git a/.bazelrc b/.bazelrc index abdb059..8277e73 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1 +1,5 @@ -build --java_language_version=17 \ No newline at end of file +build --java_language_version=17 + +# Load any settings which are specific to the current user. Needs to be *last* statement +# in this config, as the user configuration should be able to overwrite flags from this file. +try-import %workspace%/.bazelrc.user \ No newline at end of file diff --git a/.bazelrc.back b/.bazelrc.back deleted file mode 100644 index 256f6eb..0000000 --- a/.bazelrc.back +++ /dev/null @@ -1,2 +0,0 @@ -build --define=ABSOLUTE_JAVABASE='C:\Program Files\Java\jdk-17' -server --server_javabase='C:\Program Files\Java\jdk-17' \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2fae08d..d267a99 100644 --- a/.gitignore +++ b/.gitignore @@ -43,4 +43,5 @@ logs bazel-bin bazel-jobs bazel-out -bazel-testlogs \ No newline at end of file +bazel-testlogs +.bazelrc.user \ No newline at end of file diff --git a/WORKSPACE b/WORKSPACE index c8ac96e..4f52c55 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -32,8 +32,8 @@ maven_install( "org.springframework.boot:spring-boot-starter-aop:3.0.0", "io.springfox:springfox-boot-starter:3.0.0", - "org.apache.shiro:shiro-spring-boot-starter:2.0.0-alpha-2", - "org.apache.shiro:shiro-jakarta-ee:2.0.0-alpha-2", + "org.apache.shiro:shiro-spring-boot-starter:1.11.0", + "org.apache.shiro:shiro-jakarta-ee:1.11.0", "com.auth0:java-jwt:3.19.4", "org.postgresql:postgresql:42.4.0", diff --git a/build.gradle b/build.gradle index 9f38a62..ec12a81 100644 --- a/build.gradle +++ b/build.gradle @@ -27,8 +27,8 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-quartz' implementation 'org.springframework.boot:spring-boot-starter-aop' implementation 'io.springfox:springfox-boot-starter:3.0.0' - implementation('org.apache.shiro:shiro-spring:1.11.0:jakarta') { exclude group: 'org.apache.shiro', module: 'shiro-web' } - implementation 'org.apache.shiro:shiro-web:1.11.0:jakarta' + implementation('org.apache.shiro:shiro-spring:1.11.0:jakarta') { exclude group: 'org.apache.shiro', module: 'shiro-web' } + implementation 'org.apache.shiro:shiro-web:1.11.0:jakarta' implementation 'com.auth0:java-jwt:3.19.4' implementation 'org.postgresql:postgresql' From 628e969d144645d0cf27253ab8cd84fd69498b10 Mon Sep 17 00:00:00 2001 From: Arthur Ming Date: Wed, 9 Aug 2023 20:18:49 +0800 Subject: [PATCH 6/7] feat: update bazel --- WORKSPACE | 53 ++++++++++++++++++++++++++++++++++++++++++++++++---- build.gradle | 1 + 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 4f52c55..3f0af1e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -22,8 +22,49 @@ load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup") # rules_jvm_external_setup() +load("@rules_jvm_external//:specs.bzl", "maven") load("@rules_jvm_external//:defs.bzl", "maven_install") +# for https://github.com/apache/shiro/issues/891 +shiros = [ + maven.artifact( + group ="org.apache.shiro", + artifact = "shiro-spring-boot-web-starter", + classifier = "jakarta", + version = "1.11.0" + ), + maven.artifact( + group ="org.apache.shiro", + artifact = "shiro-spring-boot-starter", + classifier = "jakarta", + version = "1.11.0" + ), + maven.artifact( + group = "org.apache.shiro", + artifact = "shiro-core", + classifier = "jakarta", + version = "1.11.0", + ), + maven.artifact( + group = "org.apache.shiro", + artifact = "shiro-spring", + classifier = "jakarta", + version = "1.11.0", + exclusions = [ + maven.exclusion( + group = "javax.servlet", + artifact = "javax.servlet-api" + ), + ] + ), + maven.artifact( + group = "org.apache.shiro", + artifact = "shiro-web", + classifier = "jakarta", + version ="1.11.0", + ) +] + maven_install( artifacts = [ "org.springframework.boot:spring-boot-starter-web:3.0.0", @@ -32,16 +73,17 @@ maven_install( "org.springframework.boot:spring-boot-starter-aop:3.0.0", "io.springfox:springfox-boot-starter:3.0.0", - "org.apache.shiro:shiro-spring-boot-starter:1.11.0", - "org.apache.shiro:shiro-jakarta-ee:1.11.0", + # "org.apache.shiro:shiro-spring-boot-starter:jakarta:1.11.0", + # "org.apache.shiro:shiro-spring:jakarta:1.11.0", + # "org.apache.shiro:shiro-web:jakarta:1.11.0", "com.auth0:java-jwt:3.19.4", "org.postgresql:postgresql:42.4.0", "org.springframework.boot:spring-boot-devtools:3.0.0", "org.springframework.boot:spring-boot-starter-test:3.0.0" - ], - fetch_sources = True, + ] + shiros, + fetch_sources = True, repositories = [ "https://maven.aliyun.com/repository/public/", "https://maven.aliyun.com/nexus/content/groups/public/", @@ -49,4 +91,7 @@ maven_install( "https://maven.google.com", "https://repo1.maven.org/maven2", ], + override_targets = { + "javax.servlet:javax.servlet-api": "jakarta.servlet:jakarta.servlet-api", + }, ) \ No newline at end of file diff --git a/build.gradle b/build.gradle index ec12a81..9be6165 100644 --- a/build.gradle +++ b/build.gradle @@ -27,6 +27,7 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-quartz' implementation 'org.springframework.boot:spring-boot-starter-aop' implementation 'io.springfox:springfox-boot-starter:3.0.0' + implementation 'org.apache.shiro:shiro-spring-boot-starter:1.11.0:jakarta' implementation('org.apache.shiro:shiro-spring:1.11.0:jakarta') { exclude group: 'org.apache.shiro', module: 'shiro-web' } implementation 'org.apache.shiro:shiro-web:1.11.0:jakarta' From 80f69a5ec11768f4c4f5f07048aac47df050c9f0 Mon Sep 17 00:00:00 2001 From: Arthur Ming Date: Thu, 19 Oct 2023 15:39:24 +0800 Subject: [PATCH 7/7] fix: update shiro to 1.12.0 --- .github/workflows/ci.yaml | 2 +- BUILD.bazel | 2 +- WORKSPACE | 31 +++++++++++++------------------ build.gradle | 6 +++--- 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 31aa25e..c104c6a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -75,4 +75,4 @@ jobs: - name: Build with vite run: cd ./src/main/react && yarn && yarn build - name: Build with bazel - run: bazel build //:java-maven + run: bazel build //:jobs diff --git a/BUILD.bazel b/BUILD.bazel index b3470a5..e1328aa 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -61,7 +61,7 @@ java_library( ) java_binary( - name = "java-maven", + name = "jobs", main_class = "org.daming.jobs.JobsApplication", runtime_deps = [":java-maven-lib"], ) diff --git a/WORKSPACE b/WORKSPACE index 3f0af1e..15841d3 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -30,38 +30,36 @@ shiros = [ maven.artifact( group ="org.apache.shiro", artifact = "shiro-spring-boot-web-starter", - classifier = "jakarta", - version = "1.11.0" + version = "1.12.0", + # classifier = "jakarta", ), maven.artifact( group ="org.apache.shiro", artifact = "shiro-spring-boot-starter", + version = "1.12.0", classifier = "jakarta", - version = "1.11.0" - ), - maven.artifact( - group = "org.apache.shiro", - artifact = "shiro-core", - classifier = "jakarta", - version = "1.11.0", ), maven.artifact( group = "org.apache.shiro", artifact = "shiro-spring", + version = "1.12.0", classifier = "jakarta", - version = "1.11.0", exclusions = [ - maven.exclusion( - group = "javax.servlet", - artifact = "javax.servlet-api" + maven.exclusion( + group = "javax.servlet", + artifact = "*", + ), + maven.exclusion( + group = "org.apache.shiro", + artifact = "*", ), ] ), maven.artifact( group = "org.apache.shiro", artifact = "shiro-web", + version ="1.12.0", classifier = "jakarta", - version ="1.11.0", ) ] @@ -73,9 +71,6 @@ maven_install( "org.springframework.boot:spring-boot-starter-aop:3.0.0", "io.springfox:springfox-boot-starter:3.0.0", - # "org.apache.shiro:shiro-spring-boot-starter:jakarta:1.11.0", - # "org.apache.shiro:shiro-spring:jakarta:1.11.0", - # "org.apache.shiro:shiro-web:jakarta:1.11.0", "com.auth0:java-jwt:3.19.4", "org.postgresql:postgresql:42.4.0", @@ -94,4 +89,4 @@ maven_install( override_targets = { "javax.servlet:javax.servlet-api": "jakarta.servlet:jakarta.servlet-api", }, -) \ No newline at end of file +) diff --git a/build.gradle b/build.gradle index 9be6165..07bb22a 100644 --- a/build.gradle +++ b/build.gradle @@ -27,9 +27,9 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-quartz' implementation 'org.springframework.boot:spring-boot-starter-aop' implementation 'io.springfox:springfox-boot-starter:3.0.0' - implementation 'org.apache.shiro:shiro-spring-boot-starter:1.11.0:jakarta' - implementation('org.apache.shiro:shiro-spring:1.11.0:jakarta') { exclude group: 'org.apache.shiro', module: 'shiro-web' } - implementation 'org.apache.shiro:shiro-web:1.11.0:jakarta' + implementation 'org.apache.shiro:shiro-spring-boot-starter:1.12.0:jakarta' + implementation('org.apache.shiro:shiro-spring:1.12.0:jakarta') { exclude group: 'org.apache.shiro', module: 'shiro-web' } + implementation 'org.apache.shiro:shiro-web:1.12.0:jakarta' implementation 'com.auth0:java-jwt:3.19.4' implementation 'org.postgresql:postgresql'