From 629a6b7f32bff7f86f9d7b2c6030804c7ed497a4 Mon Sep 17 00:00:00 2001 From: Arthur Ming Date: Thu, 19 Oct 2023 18:37:31 +0800 Subject: [PATCH] feat: bump spring boot to v3.0.0 (#81) * feat: bump spring boot to v3.0.0 * fix: bug fix * fix: update fix * fix: fix all error * fix: update bazel * feat: update bazel * fix: update shiro to 1.12.0 --- .bazelrc | 6 +- .bazelrc.back | 2 - .github/workflows/ci.yaml | 2 +- .gitignore | 3 +- BUILD.bazel | 2 +- WORKSPACE | 61 ++++++++++++++++--- build.gradle | 6 +- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 4 +- .../interceptor/ControllerInterceptor.java | 2 +- .../org/daming/jobs/base/shiro/JWTFilter.java | 8 +-- .../jobs/base/shiro/ShiroUserService.java | 2 +- .../daming/jobs/base/utils/CommonUtils.java | 3 +- .../org/daming/jobs/config/ShiroConfig.java | 2 +- .../service/impl/ErrorCodeServiceImpl.java | 2 +- 15 files changed, 77 insertions(+), 30 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/.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/.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/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 41e8e40..15841d3 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -22,25 +22,63 @@ 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", + version = "1.12.0", + # classifier = "jakarta", + ), + maven.artifact( + group ="org.apache.shiro", + artifact = "shiro-spring-boot-starter", + version = "1.12.0", + classifier = "jakarta", + ), + maven.artifact( + group = "org.apache.shiro", + artifact = "shiro-spring", + version = "1.12.0", + classifier = "jakarta", + exclusions = [ + 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", + ) +] + 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", "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, + ] + shiros, + fetch_sources = True, repositories = [ "https://maven.aliyun.com/repository/public/", "https://maven.aliyun.com/nexus/content/groups/public/", @@ -48,4 +86,7 @@ maven_install( "https://maven.google.com", "https://repo1.maven.org/maven2", ], -) \ No newline at end of file + override_targets = { + "javax.servlet:javax.servlet-api": "jakarta.servlet:jakarta.servlet-api", + }, +) diff --git a/build.gradle b/build.gradle index f5bdd58..07bb22a 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,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.9.1' + 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' 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. 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..1e51764 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; 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;