做个商城网站怎么做便宜吗,kali建设网站,php网站建设实训引言,在线制作简历的网站文章目录 1 修改密码1.1 需求分析和设计1.2 代码实现1.2.1 admin/EmployeeController1.2.2 EmployeeService1.2.3 EmployeeServiceImpl 1.3 功能测试 2 bug记录 1 修改密码
完结的时候发现还有一个接口未实现。这里补充 1.1 需求分析和设计
产品原型#xff1a; 业务规则 业务规则 身份验证在修改密码之前需要验证用户的身份。这通常涉及到输入当前的密码以证明用户有权限修改密码。
密码复杂度要求新密码应该满足一定的复杂度要求比如长度、大小写字母、数字和特殊字符的组合等。
密码加密存储密码在存储时应该进行加密处理比如使用哈希加盐的方式以防止密码泄露后被轻易破解。
异常处理在密码修改过程中应该有适当的异常处理机制比如密码不匹配时的友好提示或者密码修改失败时的错误信息。
接口设计
package com.sky.dto;import lombok.Data;import java.io.Serializable;Data
public class PasswordEditDTO implements Serializable {//员工idprivate Long empId;//旧密码private String oldPassword;//新密码private String newPassword;}
1.2 代码实现
1.2.1 admin/EmployeeController /*** 修改密码** param passwordEditDTO* return* throws Exception*/PutMapping(/editPassword)ApiOperation(修改密码)public Result editPassword(RequestBody PasswordEditDTO passwordEditDTO){log.info(修改密码{}, passwordEditDTO);employeeService.editPassword(passwordEditDTO);return Result.success();}1.2.2 EmployeeService /*** 更新员工信息* param employeeDTO*/void update(EmployeeDTO employeeDTO);
}
1.2.3 EmployeeServiceImpl
/*** 编辑员工密码** param passwordEditDTO*/Overridepublic void editPassword(PasswordEditDTO passwordEditDTO) {String oldPassword passwordEditDTO.getOldPassword();String newPassword passwordEditDTO.getNewPassword();//获取员工idLong empId BaseContext.getCurrentId();//1.根据id查询员工信息Employee employee employeeMapper.getById(empId);//2. 密码比对String encryptedOldPassword DigestUtils.md5DigestAsHex(oldPassword.getBytes());if (!encryptedOldPassword.equals(employee.getPassword())) {//密码错误throw new PasswordErrorException(MessageConstant.PASSWORD_ERROR);}//3. 更新密码String encryptedNewPassword DigestUtils.md5DigestAsHex(newPassword.getBytes());employee.setPassword(encryptedNewPassword);employee.setUpdateTime(LocalDateTime.now());employee.setUpdateUser(empId);employeeMapper.update(employee);}
1.3 功能测试 2 bug记录 o.s.web.servlet.PageNotFound : No mapping for PUT /user/order/cancel/8 检查Controller中路径是否出错,函数是否放错位写在其他XxxxController Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: Optional int parameter ‘pageNum’ is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.] with root cause java.lang.IllegalStateException: Optional int parameter ‘pageNum’ is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type. 存在可选int参数’pageNum’但由于被声明为基本类型因此无法转换为空值。考虑将其声明为对应基本类型的对象包装器 //Controller中命名page
public ResultPageResultpage(int page,intpageSize,Integerstatus){
PageResultpageResultorderService.pageQueryUser(page,pageSize,status);
returnResult.success(pageResult);
//Service中命名pageNum
Page Result pageQueryUser(int pageNum,intpageSize,Integerstatus);ERROR 29228 — [nio-8080-exec-9] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: 无效的密钥格式] with root cause java.lang.RuntimeException: 无效的密钥格式 微信小程序没有密钥 ERROR 8716 — [io-8080-exec-10] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘user_id’ in ‘class com.sky.entity.Orders’] with root cause Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to localhost/:6379] with root cause 启动Redis org.springframework.data.redis.serializer.SerializationException: Cannot deserialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?; nested exception is java.io.EOFException 这个错误表明在尝试对 Redis 中的数据进行反序列化时出现了问题。根据错误信息这可能是由于尝试反序列化不完整的字节数组导致的。 在处理这个问题时有几种可能的解决方案
检查数据完整性 确保在进行序列化和存储数据时数据没有发生截断或丢失。这可能需要检查数据的存储和读取过程以确保整个字节数组都被正确地写入和读取。检查序列化器配置 确保在 RedisTemplate 或其他涉及到序列化的地方所使用的序列化器是正确配置的。你需要保证数据的序列化和反序列化使用的是相同的序列化器。检查数据格式 确保反序列化操作的目标对象与实际存储的数据格式相匹配。如果你对存储的数据进行了更改可能需要更新代码来处理新的数据结构。排查数据内容 如果可能的话检查实际存储在 Redis 中的数据内容。有时候问题可能源于存储了不符合预期格式的数据。 最后请确保在处理 Redis 数据时采用了健壮的异常处理机制以便能够更好地理解和排查潜在的数据问题。 希望这些信息能够帮助你解决问题。如果你需要更多帮助欢迎随时与我联系。
com.sky.config
//设置rediskey的序列化器
redisTemplate.setKeySerializer(newStringRedisSerializer());
//设置redisvalue的序列化器
redisTemplate.setValueSerializer(newStringRedisSerializer());
//设置redishash的序列化器
redisTemplate.setHashValueSerializer(newStringRedisSerializer());Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String] with root cause{ “timestamp”: 1717330318869, “status”: 500, “error”: “Internal Server Error”, “path”: “/admin/shop/1” } java.lang.Integer cannot be cast to java.lang.String Fitten Code 根据你提供的错误信息看起来在处理请求 “/admin/shop/1” 时发生了内部服务器错误。具体的错误根本原因是 “java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String”。 这个错误通常表示代码试图将一个整数类型的数据转换为字符串类型时出现了类型转换错误。根据报错的上下文可能是在将整数类型的数据用作字符串处理时出现了问题。 可能的问题点 路径参数处理错误 如果你的代码中使用了路径参数来表示商品或店铺的标识而在处理路径参数时出现了类型转换错误就会抛出这个异常。需要检查对路径参数的解析和使用是否正确。数据操作错误 如果你从数据源比如数据库、缓存等中取出了某个整数类型的值并且尝试将其作为字符串使用也会出现这个错误。需要确保在操作数据时进行了正确的类型转换。 要解决这个问题你需要根据具体的业务逻辑和异常发生的上下文来检查代码并确保数据类型的正确使用。 不写范型就行 APPLICATION FAILED TO START Description: Failed to bind properties under ‘sky.wechat.appid’ to java.lang.String: Property: sky.wechat.appid
Value: ${sky.wechat.appid}
Origin: class path resource [application.yml] - 58:12
Reason: java.lang.IllegalArgumentException: Circular placeholder reference sky.wechat.appid in property definitionsAction: Update your application’s configuration Process finished with exit code 1 !!! 这个问题就看看application的配置!!! 2024-06-11 19:26:06.852 ERROR 32748 — [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘user_id’ in ‘class com.sky.entity.ShoppingCart’] with root cause 这个异常表明在处理请求时发生了错误具体而言是因为MyBatis无法找到名为 ‘user_id’ 的属性的 getter 方法。可能有几个原因会导致这种情况 3. 属性名错误确保你的实体类 com.sky.entity.ShoppingCart 中存在名为 ‘user_id’ 的属性并且有对应的 getter 方法。 4. 配置错误检查你的 MyBatis 映射文件以确保正确地映射了数据库列和实体类的属性包括 ‘user_id’。 5. 数据库查询错误如果你在执行 SQL 查询时指定了 ‘user_id’但实际上实体类中并不存在该属性就会导致这个问题。 为了排除这个问题可以按照以下步骤进行排查 • 确保实体类 com.sky.entity.ShoppingCart 中存在名为 ‘user_id’ 的属性并且有对应的 getter 方法。 • 检查 MyBatis 映射文件通常是 XML 文件中与 ‘user_id’ 相关的属性映射是否正确。 • 跟踪具体的请求处理流程确认是在哪个环节出现了这个异常有助于定位问题所在。 一旦找到了问题所在针对性地进行修复即可。如果以上方法仍无法解决问题可能需要进一步检查程序的逻辑和配置或者提供更多的代码和细节信息进行分析。 D:\Code\Course\java-learning\sky-take-out\sky-server\src\main\java\com\sky\service\impl\AddressBookServiceImpl.java:5:22 java: 找不到符号 符号: 类 AddressBookMapper 位置: 程序包 com.sky.mapper D:\Code\Course\java-learning\sky-take-out\sky-server\src\main\java\com\sky\service\impl\AddressBookServiceImpl.java:6:23 java: 找不到符号 符号: 类 AddressBookService 位置: 程序包 com.sky.service D:\Code\Course\java-learning\sky-take-out\sky-server\src\main\java\com\sky\service\impl\AddressBookServiceImpl.java:15:48 java: 找不到符号 符号: 类 AddressBookService D:\Code\Course\java-learning\sky-take-out\sky-server\src\main\java\com\sky\service\impl\AddressBookServiceImpl.java:17:13 java: 找不到符号 符号: 类 AddressBookMapper 位置: 类 com.sky.service.impl.AddressBookServiceImpl Fitten Code 这些错误表明编译器无法找到名为 AddressBookMapper 和 AddressBookService 的类和接口。这通常是因为编译器无法在指定的位置找到所需的类或接口。 在大多数情况下这种错误是由以下原因引起的 6. 包名错误确保 AddressBookMapper 和 AddressBookService 类在正确的包中。在你的示例中它们应该分别位于 com.sky.mapper 和 com.sky.service 包下。 7. 缺失依赖检查你的项目依赖确保相关的包或模块已经正确导入并设置为依赖项。 8. 编译路径错误有时编译器无法在指定的路径中找到所需的类或接口。确保你的编译路径配置正确并包含了这些类和接口所在的位置。 9. 类或接口未定义最显而易见的情况是这些类和接口可能确实未定义。在这种情况下你需要创建它们或者从其他地方获取它们的定义。 下面是一个可能的排查步骤 • 确保 AddressBookMapper 和 AddressBookService 类分别位于 com.sky.mapper 和 com.sky.service 包中并且包名和类名的大小写拼写与代码中的引用一致。 • 检查项目的依赖配置确保相关的包或模块已经正确导入并设置为依赖项。 • 确保编译路径配置正确包含了这些类和接口所在的位置。 • 如果以上步骤都正确无误但问题依然存在可能需要检查是否缺少了必要的依赖项或者类和接口未被正确定义。 通过排查这些可能引起问题的原因你应该能够定位并解决编译错误。 导入新功能代码,重新打开Maven在sky_take_out使用compile一下 2024-06-12 15:40:55.795 ERROR 15856 — [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: Field orderService in com.sky.controller.user.OrderController required a bean of type ‘com.sky.service.OrderService’ that could not be found. The injection point has the following annotations: - org.springframework.beans.factory.annotation.Autowired(requiredtrue) Action: Consider defining a bean of type ‘com.sky.service.OrderService’ in your configuration. Disconnected from the target VM, address: ‘127.0.0.1:57369’, transport: ‘socket’ Process finished with exit code 1 Fitten Code 这个错误信息表明 Spring 在启动应用程序时无法找到类型为 com.sky.service.OrderService 的 bean。通常情况下这种错误是由缺少 bean 的定义或者扫描路径错误引起的。 要解决这个问题你可以尝试以下几个步骤 确认 Service 类被正确扫描和组件化: 确保 com.sky.service.OrderService 类上使用了 Service 注解或者被正确标记为组件。在 Spring Boot 应用中通常使用了 SpringBootApplication 的类所在的包及其子包将会被自动扫描你需要确保 com.sky.service.OrderService 类在扫描路径下。查看是否存在正确的 bean 配置: 确保在配置类如使用 Configuration 注解的类或者 XML 配置文件中存在了 com.sky.service.OrderService 类的 bean 配置。排查依赖注入位置: 如果 Autowired 注解标记的地方并非预期的位置可能会出现这种错误。请检查 orderService 字段所在的类确认它是否应该被注入为一个 bean。查看启动日志: 在启动日志中查看是否有针对 bean 扫描和自动配置相关的日志有时会通过日志信息找到问题所在。手动创建 bean: 如果以上步骤都不能解决问题你可以尝试手动在配置类中创建 com.sky.service.OrderService 的 bean。 基于以上步骤你可以逐一排查是否缺少了对 com.sky.service.OrderService 的正确定义。一旦找到了问题所在并修复了配置你的应用程序应该可以成功启动了。