Spring和MybatisPlus踩坑
2024-09-16 17:31:25

发现build后还有原来的代码

build只会加缓存,不会减缓存,因此如果删除文件,需要rebuild。

Bean冲突

遇到了processBean冲突,排查后发现是框架文件里有这个名称的bean,因此换个名称就可以解决。不要把名称设的太宽泛。

MybatisPlus学习

过于细化的框架损失自由度,并且会引起很多难以解决的bug,只有在组里有前人对框架非常熟悉,且框架经过检验时,使用框架才好。

所以采用适用性相对较广的MybatisPlus。

后端设置UUID:

1
2
@TableId(type = IdType.ASSIGN_UUID)  
private String id;

后端分页:

1
2
3
4
5
6
7
8
9
//ProcessingMapper.java
@Select("SELECT * FROM " + TABLE_NAME)
IPage<Processing> selectPageVo(IPage<?> page);

//ProcessingService.java
public IPage<Processing> getProcessingPage(int currentPage, int pageSize){
Page<Processing> page = new Page<>(currentPage, pageSize);
return processingMapper.selectPageVo(page);
}

Post的时候后端一直报错

1
错误: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'rawData' in 'class com.jeeplus.processmanage.domain.Processing'

一直在前端找,都没找到哪里有rawData这个东西,后来发现是后端的Mapper当时复制了另一个文件,里面有insert这个东西,自己没有注意到。所以,出现莫名其妙的错误时,要回想一下自己所没有注意到,特别是复制黏贴的事物复制黏贴还是少用为好。

报SQL语句错误

procedure是一个保留关键字,不能作为列名。

1
错误: ### Error updating database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'procedure, equipment_used, operator_info, material_id ) VALUES ( '183558877960' at line 4 ### The error may exist in com/jeeplus/processmanage/mapper/ProcessingMapper.java (best guess) ### The error may involve com.jeeplus.processmanage.mapper.ProcessingMapper.insert-Inline ### The error occurred while setting parameters ### SQL: INSERT INTO process_process ( id, technique, procedure, equipment_used, operator_info, material_id ) VALUES ( ?, ?, ?, ?, ?, ? ) ### Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'procedure, equipment_used, operator_info, material_id ) VALUES ( '183558877960' at line 4 ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'procedure, equipment_used, operator_info, material_id ) VALUES ( '183558877960' at line 4

在 SQL 语言中,PROCEDURE 是一个保留字,用于定义存储过程。存储过程是一组为了完成特定功能的 SQL 语句集合,它可以在数据库中被保存和重用。

可见sql和spring是要注意命名错误的。

上一页
2024-09-16 17:31:25