From 3cb87d7c0c65abcb6b58ec227aa25f2e997db3d0 Mon Sep 17 00:00:00 2001 From: "Jeffrey.Cao" Date: Thu, 31 Jul 2025 17:26:46 +0800 Subject: [PATCH] * Upgrade AutoLoadCache to support Spring Boot 3.5.x with Java 17 --- autoload-cache-spring-boot-starter/pom.xml | 21 +++++++-- .../admin/HTTPBasicAuthorizeAttribute.java | 16 +++---- .../AutoloadCacheAutoConfigure.java | 2 +- .../AutoloadCacheProperties.java | 2 +- ...ot.autoconfigure.AutoConfiguration.imports | 3 ++ .../cache/demo/CacheDemoApplication.java | 2 +- .../cache/demo/test/UserServiceTest.java | 4 +- .../src/test/resources/init_table.sql | 5 +- .../src/test/resources/mybatis/UserMapper.xml | 22 ++++----- pom.xml | 46 ++++++++++--------- 10 files changed, 73 insertions(+), 50 deletions(-) create mode 100644 autoload-cache-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports diff --git a/autoload-cache-spring-boot-starter/pom.xml b/autoload-cache-spring-boot-starter/pom.xml index 41e0eac..f43071f 100644 --- a/autoload-cache-spring-boot-starter/pom.xml +++ b/autoload-cache-spring-boot-starter/pom.xml @@ -14,13 +14,14 @@ autoload-cache spring boot starter. false + 3.5.3 org.springframework.boot - spring-boot-starter-parent - 2.1.0.RELEASE + spring-boot-dependencies + ${spring-boot.version} pom import @@ -135,7 +136,7 @@ org.mybatis.spring.boot mybatis-spring-boot-starter - 1.3.0 + 3.0.5 test true @@ -178,6 +179,20 @@ compile true + + org.projectlombok + lombok + + + junit + junit + test + + + org.junit.vintage + junit-vintage-engine + test + diff --git a/autoload-cache-spring-boot-starter/src/main/java/com/jarvis/cache/admin/HTTPBasicAuthorizeAttribute.java b/autoload-cache-spring-boot-starter/src/main/java/com/jarvis/cache/admin/HTTPBasicAuthorizeAttribute.java index 3d26ffd..ca76f83 100644 --- a/autoload-cache-spring-boot-starter/src/main/java/com/jarvis/cache/admin/HTTPBasicAuthorizeAttribute.java +++ b/autoload-cache-spring-boot-starter/src/main/java/com/jarvis/cache/admin/HTTPBasicAuthorizeAttribute.java @@ -3,14 +3,14 @@ import java.io.IOException; import java.util.Base64; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.http.HttpStatus; diff --git a/autoload-cache-spring-boot-starter/src/main/java/com/jarvis/cache/autoconfigure/AutoloadCacheAutoConfigure.java b/autoload-cache-spring-boot-starter/src/main/java/com/jarvis/cache/autoconfigure/AutoloadCacheAutoConfigure.java index 23fbeaf..709ee6b 100644 --- a/autoload-cache-spring-boot-starter/src/main/java/com/jarvis/cache/autoconfigure/AutoloadCacheAutoConfigure.java +++ b/autoload-cache-spring-boot-starter/src/main/java/com/jarvis/cache/autoconfigure/AutoloadCacheAutoConfigure.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.List; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator; import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; diff --git a/autoload-cache-spring-boot-starter/src/main/java/com/jarvis/cache/autoconfigure/AutoloadCacheProperties.java b/autoload-cache-spring-boot-starter/src/main/java/com/jarvis/cache/autoconfigure/AutoloadCacheProperties.java index 0436c2b..99b7ace 100644 --- a/autoload-cache-spring-boot-starter/src/main/java/com/jarvis/cache/autoconfigure/AutoloadCacheProperties.java +++ b/autoload-cache-spring-boot-starter/src/main/java/com/jarvis/cache/autoconfigure/AutoloadCacheProperties.java @@ -1,6 +1,6 @@ package com.jarvis.cache.autoconfigure; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/autoload-cache-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/autoload-cache-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000..f59821b --- /dev/null +++ b/autoload-cache-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1,3 @@ +com.jarvis.cache.autoconfigure.AutoloadCacheManageConfiguration +com.jarvis.cache.autoconfigure.DistributedLockConfiguration +com.jarvis.cache.autoconfigure.AutoloadCacheAutoConfigure \ No newline at end of file diff --git a/autoload-cache-spring-boot-starter/src/test/java/com/jarvis/cache/demo/CacheDemoApplication.java b/autoload-cache-spring-boot-starter/src/test/java/com/jarvis/cache/demo/CacheDemoApplication.java index ef77fd1..cada592 100644 --- a/autoload-cache-spring-boot-starter/src/test/java/com/jarvis/cache/demo/CacheDemoApplication.java +++ b/autoload-cache-spring-boot-starter/src/test/java/com/jarvis/cache/demo/CacheDemoApplication.java @@ -35,7 +35,7 @@ public void onApplicationEvent(ApplicationReadyEvent event) { userMapper.allUsers(); UserCondition condition = new UserCondition(); - PageRequest page =new PageRequest(1, 10); + PageRequest page = PageRequest.of(1, 10); condition.setPageable(page); condition.setStatus(1); userMapper.listByCondition(condition); diff --git a/autoload-cache-spring-boot-starter/src/test/java/com/jarvis/cache/demo/test/UserServiceTest.java b/autoload-cache-spring-boot-starter/src/test/java/com/jarvis/cache/demo/test/UserServiceTest.java index 8fa5141..cb0d673 100644 --- a/autoload-cache-spring-boot-starter/src/test/java/com/jarvis/cache/demo/test/UserServiceTest.java +++ b/autoload-cache-spring-boot-starter/src/test/java/com/jarvis/cache/demo/test/UserServiceTest.java @@ -49,7 +49,7 @@ public void test1Add() throws Exception { userService.doLogin("tmp2", "aaaa3"); UserCondition condition = new UserCondition(); - Pageable pageable = new PageRequest(0, 10); + Pageable pageable = PageRequest.of(0, 10); condition.setPageable(pageable); List list = userService.listByCondition(condition); @@ -84,7 +84,7 @@ public void testMagic() throws Exception { userService.getUserById(1L); UserCondition condition = new UserCondition(); - Pageable pageable = new PageRequest(0, 5); + Pageable pageable = PageRequest.of(0, 5); condition.setPageable(pageable); List list = userService.listByCondition(condition); diff --git a/autoload-cache-spring-boot-starter/src/test/resources/init_table.sql b/autoload-cache-spring-boot-starter/src/test/resources/init_table.sql index 0fc0da7..a917f69 100644 --- a/autoload-cache-spring-boot-starter/src/test/resources/init_table.sql +++ b/autoload-cache-spring-boot-starter/src/test/resources/init_table.sql @@ -1 +1,4 @@ -create table if not exists user(id int not null primary key auto_increment, name varchar(100), password varchar(10), status int); \ No newline at end of file +create table if not exists `user`(id int not null primary key auto_increment, + name varchar(100), + password varchar(10), + status int); \ No newline at end of file diff --git a/autoload-cache-spring-boot-starter/src/test/resources/mybatis/UserMapper.xml b/autoload-cache-spring-boot-starter/src/test/resources/mybatis/UserMapper.xml index 6f379b5..b0b7d86 100644 --- a/autoload-cache-spring-boot-starter/src/test/resources/mybatis/UserMapper.xml +++ b/autoload-cache-spring-boot-starter/src/test/resources/mybatis/UserMapper.xml @@ -16,20 +16,20 @@ select - from user + from `user` where id = #{id} @@ -70,7 +70,7 @@ - insert into user(name, password, status) + insert into `user`(name, password, status) values(#{name}, #{password}, 1) - update user + update `user` password = #{password}, status = #{status}, @@ -92,11 +92,11 @@ - update user set status = 0 where id = #{id} + update `user` set status = 0 where id = #{id} - update user set status = 0 where + update `user` set status = 0 where id = #{id} diff --git a/pom.xml b/pom.xml index a73094f..6e11f22 100644 --- a/pom.xml +++ b/pom.xml @@ -13,14 +13,14 @@ Use AOP and Annotation manage cache. https://github.com/qiujiayu/AutoLoadCache - 7.2.1 - 1.8 - 1.8 + 8.0.0 + 17 + 17 UTF-8 UTF-8 - 5.2.21.RELEASE - 2.8.2 - 3.8.1 + 6.2.8 + 3.1.3 + 3.13.0 false @@ -56,20 +56,27 @@ + + org.springframework + spring-framework-bom + ${spring-framework.version} + pom + import + org.slf4j slf4j-api - 1.7.23 + 2.0.17 org.apache.commons commons-compress - 1.21 + 1.26.1 org.apache.commons commons-pool2 - 2.4.2 + 2.12.1 com.alibaba @@ -79,17 +86,12 @@ org.aspectj aspectjrt - 1.8.10 - - - org.springframework - spring-expression - ${spring.version} + 1.9.24 io.lettuce lettuce-core - 5.3.1.RELEASE + 6.6.0.RELEASE redis.clients @@ -119,7 +121,7 @@ com.fasterxml.jackson.core jackson-databind - 2.14.0-rc1 + 2.19.1 cglib @@ -149,12 +151,12 @@ org.apache.commons commons-lang3 - 3.10 + 3.12.0 com.google.protobuf protobuf-java - 3.16.3 + 3.24.3 com.googlecode.combinatoricslib @@ -164,7 +166,7 @@ junit junit - 4.13.1 + 4.13.2 test @@ -208,7 +210,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.1.1 + 3.8.0 package @@ -216,7 +218,7 @@ jar - 8 + 17