网站文件大小,英选 网站开发,网络规划设计师教程 下载,网络网站开发设计前言
最近想着把大火的deepseek 迁移到小程序里#xff0c;基于刷题小程序的数据库做一个RAG应用#xff0c;来进一步扩展答案解析#xff0c;帮助用户解答相关问题。但是由于之前做的项目都要老了#xff0c;并不支持spring 的AI模块#xff0c;因此#xff0c;我打算先…前言
最近想着把大火的deepseek 迁移到小程序里基于刷题小程序的数据库做一个RAG应用来进一步扩展答案解析帮助用户解答相关问题。但是由于之前做的项目都要老了并不支持spring 的AI模块因此我打算先升级一下系统。
一、升级JDK 1.8 到 JDK 17
1、首先从官网上下载一个JDK17的包windows系统可能有这两种包压缩包和安装包 直接下载压缩包放在一个中文目录下然后修改环境变量。 然后看一下java版本 java --version 是否修改成功。 修改项目中的设置 如下 二、升级Springboot 2.x 到 Springboot 3.x 修改pom文件 parentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion3.2.0/versionrelativePath//parent propertiesjava.version17/java.version/properties
这里面需要注意的东西还挺多的
1、javax.servlet.*相关的类找不到需要切换依赖为jakarta.servlet。修改javax.servlet.*为jakarta.servlet.*。 !--jakarta.servlet start --dependencygroupIdjakarta.servlet/groupIdartifactIdjakarta.servlet-api/artifactId/dependency!--jakarta.servlet end --2.、mybatis-plus-boot-starter !-- mybatis-plus start--dependencygroupIdcom.baomidou/groupIdartifactIdmybatis-plus-spring-boot3-starter/artifactIdversion3.5.5/version/dependency!-- mybatis-plus end--3、redis
spring.data.redis.host127.0.0.1
#Redis服务器连接端口
spring.data.redis.port6379
#连接池最大连接数使用负值表示没有限制
spring.data.redis.lettuce.pool.max-active20
#连接池最大阻塞等待时间使用负值表示没有限制
spring.data.redis.lettuce.pool.max-wait-1
#连接池中的最大空闲连接
spring.data.redis.lettuce.pool.max-idle5
#连接池中的最小空闲连接
spring.data.redis.lettuce.pool.min-idle0
#连接超时时间毫秒
spring.data.redis.timeout1800000
4、commons-pool2 Spring Boot 的 spring-boot-starter-data-redis 依赖了 Lettuce 作为 Redis 客户端。 Lettuce 依赖于 commons-pool2 来实现连接池功能。 因此我们也需要更新一下commons-pool2的版本。 dependencygroupIdorg.apache.commons/groupIdartifactIdcommons-pool2/artifactIdversion2.11.1/version/dependency
4、Spring-Security
咋WebSecurityConfig显示的注册authenticationManager为一个Bean Beanpublic AuthenticationManager authenticationManager(AuthenticationConfiguration config) throws Exception {return config.getAuthenticationManager();}
使用SecurityFilterChain替代WebSecurityConfigurerAdapter
Beanpublic SecurityFilterChain securityFilterChain(HttpSecurity http,CustomizeAuthenticationEntryPoint customizeAuthenticationEntryPoint,CustomizeAccessDeniedHandler customizeAccessDeniedHandler) throws Exception {http.sessionManagement(session - session.sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED)).authenticationProvider(thirdLoginAuthenticationProvider).authorizeHttpRequests(authorize - authorize.requestMatchers(/swagger-resources/configuration/ui,/swagger-resources,/swagger-resources/configuration/security,/swagger-ui.html,).permitAll().anyRequest().authenticated()).exceptionHandling(exception - exception.accessDeniedHandler(customizeAccessDeniedHandler).authenticationEntryPoint(customizeAuthenticationEntryPoint)).cors(cors - cors.configure(http)).csrf(csrf - csrf.disable());return http.build();}
Spring-Security 6.x的版本中对于session的管理也发生了一些变化需要手动将 SecurityContext 保存到 HttpSession 中。 HttpSession session request.getSession();session.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, SecurityContextHolder.getContext());修改到这里位置就可以启动项目了。