这是dao方法
int insertRecord(CustmoerDownRecordDO custmoerDownRecordDO,String taskType); }
这是xml
<insert id="insertRecord" parameterType="com.yz.api.pojo.CustomerDownRecordDO"> insert into custmoer_down_record(task_type,customer_id,file_info_id, bucket_name,object_name,gmt_create,created_by,gmt_modify) values ( #{taskType}, #{customer_id}, #{file_info_id}, #{bucket_name}, #{object_name}, #{gmt_create}, #{created_by}, #{gmt_modify} ) </insert>
这是service
public int insertRecord(CustmoerDownRecordDO custmoerDownRecord, String taskType) { try { //记录客户下载文件信息 FileInfoDO fileInfoMessage = fileInfoDao.select(taskType); custmoerDownRecord.setTaskType(taskType); custmoerDownRecord.setCustomerId(taskType); custmoerDownRecord.setFileInfoId(fileInfoMessage.getId()); custmoerDownRecord.setBucketName((fileInfoMessage.getBucketName())); custmoerDownRecord.setObjectName(fileInfoMessage.getObjectName()); custmoerDownRecord.setGmtCreate(fileInfoMessage.getGmtCreate()); custmoerDownRecord.setGmtModify(fileInfoMessage.getGmtModify()); custmoerDownRecordDao.insertRecord(custmoerDownRecord, taskType); }catch(Exception e){ logger.error("记录用户下载文件异常",e); } return 0;
这是contorller
@Autowired private ApiService apiService; @RequestMapping("/api/v1") public ResultJson selectByType(HttpServletRequest request, HttpServletResponse response)throws Exception{ String key = request.getHeader(ParamConstants.X_ACCESS_LKEY); String task_type = request.getHeader(ParamConstants.TASK_TYPE); ResultJson result = null; result = ResultJson.ok().data(apiService.selectByType(task_type)); CustmoerDownRecordDO custmoerDownRecordDO = new CustmoerDownRecordDO(); apiService.insertRecord(custmoerDownRecordDO,task_type); return result;
大概就是我要根据tasktype来判断用户下载的是哪文件 然后把一些属性拿出来记录一下
就一直报错
CustmoerDownRecordDO CustomerDownRecordDO 类名错了 错误提示很明显了
Cause: java.lang.ClassNotFoundException: Cannot find class: com.yz.api.pojo.CustomerDownRecordDO
mybatis学习笔记:https://edu.csdn.net/course/detail/10551
Error creating bean with name 'baseCenterApi': Unsatisfied dependency expressed through field 'apiService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'apiServiceImpl': Unsatisfied dependency expressed through field 'fileInfoDao'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fileInfoDao' defined in file [/Users/yuanzhe/Desktop/study/apiaaa/target/classes/com/yz/api/mapper/FileInfoDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [/Users/yuanzhe/Desktop/study/apiaaa/target/classes/mapper/CustmoerDownRecordMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'file [/Users/yuanzhe/Desktop/study/apiaaa/target/classes/mapper/CustmoerDownRecordMapper.xml]'. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.yz.api.pojo.CustomerDownRecordDO'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.yz.api.pojo.CustomerDownRecordDO
但我如果把insert语句注视掉 就没问题 mapper service 注解什么的都加 网上的方法都不行
问问大佬们
1.从报错的内容看,是找不到对应的类
2.检查com.yz.api.pojo.CustomerDownRecordDO这个路径是否有错误
3.数据层
custmoerDownRecordDao.insertRecord(custmoerDownRecord, taskType);
这个方法,不需要taskType这个参数单独传,你在业务层中已经把这个参数放到了custmoerDownRecord对象中
您好,我是有问必答小助手,你的问题已经有小伙伴为您解答了问题,您看下是否解决了您的问题,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632