ruoyi springboot 开发笔记

📅 2026/7/16 20:54:45
ruoyi springboot 开发笔记
1、跳过密码校验实现原理是从库中查询出密码直接用库中密码跳过加密进行密码比较。重写DaoAuthenticationProvider.java密码校验方法package com.zscq.framework.provider; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.authentication.dao.DaoAuthenticationProvider; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.AuthenticationException; import org.springframework.security.crypto.factory.PasswordEncoderFactories; public class LoginAuthenticationProvider extends DaoAuthenticationProvider { public LoginAuthenticationProvider(UserDetailsService userDetailsService) { super(); // 这个地方一定要对userDetailsService赋值不然userDetailsService是null (这个坑有点深) setUserDetailsService(userDetailsService); } SuppressWarnings(deprecation) protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { if (authentication.getCredentials() null) { this.logger.debug(Failed to authenticate since no credentials provided); throw new BadCredentialsException(this.messages.getMessage(AbstractUserDetailsAuthenticationProvider.badCredentials, Bad credentials)); } else { String presentedPassword authentication.getCredentials().toString(); if(presentedPassword.equals(userDetails.getPassword())){ return; } if (!PasswordEncoderFactories.createDelegatingPasswordEncoder().matches(presentedPassword, userDetails.getPassword())) { this.logger.debug(Failed to authenticate since password does not match stored value); throw new BadCredentialsException(this.messages.getMessage(AbstractUserDetailsAuthenticationProvider.badCredentials, Bad credentials)); } } } }SecurityConfig.java 中增加SysPasswordService.java中增加SysLoginService.java中之前的login方法也需要调整否则会有问题2、禁用swaggerapplication.yml中3、java 执行c语言代码!-- java调用执行c语言-- dependency groupIdnet.java.dev.jna/groupId artifactIdjna/artifactId version5.14.0/version /dependency// 定义一个接口继承自 Library public interface ExampleLibrary extends Library { // 不使用的地方可以声明为 null ExampleLibrary INSTANCE null; int sim_main(Integer params); } // 动态获取共享库路径 // 加载共享库 ExampleLibrary exampleLibrary (ExampleLibrary)Native.load(basePath, ExampleLibrary.class); // 调用 C 函数 exampleLibrary.sim_main(numberofTimes); // 卸载dll Class myNative Class.forName(com.sun.jna.Native); Method method myNative.getDeclaredMethod(dispose, new Class[]{}); method.setAccessible(true); method.invoke(myNative, new Object[]{});4、java 判断list中对象是否形成环public static boolean hasCycle(ListTProjectNode nodes) { SetString visited new HashSet(); for (TProjectNode node : nodes) { String currentNodeId node.getNodeId(); // 处理当前节点的 nextNodeId String nextNodeId node.getNextNodeId(); if (visited.contains(currentNodeId)) { return true; // 如果已经访问过当前节点说明有环 } visited.add(currentNodeId); // 检查 nextNodeId 是否存在于 nodes 中 if (nextNodeId ! null) { boolean foundNextNode false; for (TProjectNode nextNode : nodes) { if (nextNode.getNodeId().equals(nextNodeId)) { foundNextNode true; break; } } // 如果 nextNodeId 不在列表中跳出循环 if (!foundNextNode) { break; } } } return false; // 如果没有重复访问说明无环 } public static void main(String[] args) { TProjectNode tProjectNode1 new TProjectNode(); tProjectNode1.setNodeId(1); tProjectNode1.setNextNodeId(2); TProjectNode tProjectNode2 new TProjectNode(); tProjectNode2.setNodeId(2); tProjectNode2.setNextNodeId(3); TProjectNode tProjectNode3 new TProjectNode(); tProjectNode3.setNodeId(3); tProjectNode3.setNextNodeId(1); TProjectNode tProjectNode4 new TProjectNode(); tProjectNode4.setNodeId(4); tProjectNode4.setNextNodeId(5); // 示例数据 ListTProjectNode projectNodes new ArrayList(); projectNodes.add(tProjectNode3); projectNodes.add(tProjectNode2); projectNodes.add(tProjectNode1); projectNodes.add(tProjectNode4); System.out.println(是否有环: hasCycle(projectNodes)); }5、MySQL批量迁移数据库复制Data下的所有库文件和ibdata1(这个不复制navicate中只显示库不显示表)6、mysql数据过30分钟自动删除步骤1创建一个数据库表CREATE TABLE my_table ( id INT AUTO_INCREMENT PRIMARY KEY, data VARCHAR(255), created_at DATETIME DEFAULT CURRENT_TIMESTAMP );步骤2插入一些测试数据INSERT INTO my_table (data) VALUES (测试数据1); INSERT INTO my_table (data) VALUES (测试数据2);步骤3创建触发器或定时任务在MySQL中并不直接支持自动删除数据的触发器功能。但是我们可以利用 EVENT 来创建一个定时任务自动删除超过30分钟的数据。首先我们需要确认我们的 MySQL 服务器支持事件调度。使用以下命令启用事件调度器SET GLOBAL event_scheduler ON;接下来我们创建一个事件来定期执行删除操作CREATE EVENT delete_old_records ON SCHEDULE EVERY 1 MINUTE DO DELETE FROM my_table WHERE created_at NOW() - INTERVAL 30 MINUTE;这个事件每分钟运行一次会删除 created_at 字段值在当前时间之前30分钟的数据。7、windows 测目的端口是否开放# powershell中执行 Test-NetConnection 192.168.0.159 -Port 5672 -InformationLevel Quiet