Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自建Cloud模块找不到Mapper解决完之后,主键IdType.ASSIGN_ID新增会重复 #6230

Open
pinktigerkk opened this issue May 17, 2024 · 1 comment

Comments

@pinktigerkk
Copy link

各位大佬请教一个问题通过自动代码生成的基础代码之后我写了一个简单的查询但是一直报错
org.apache.ibatis.binding.BindingException:Invalid bound statement (not found)
找不到Mapper.xml的文件
YA}FPPR(GM}C`@NBZI R_BU

ATF CVBJ(OLU J8`T3MAB2T

然后我把xml文件挪到了resources下顺利找到了Mapper.xml的文件,但是在新增的时候会偶尔报错Duplicate entry '' for key 'PRIMARY'主键重复
9G)6O%O@S%(HS VM$5I@{V3

然后我把实体类的Id改为ASSIGN_UUID之后就会正常新增不会重复请问有哪位大佬能解答一下这个问题
Z~(JS3X9ZR5LX{`ES}ESYWS
M$ L_29M79%J8Z3T(H85NRX

image

在启动类我手动加上了
@MapperScan({"org.jeecg..mapper."})因为之前没加会找不到Mapper文件

请问这个ASSIGN_ID(3)主键重复是因为我把Mapper.xml挪到了resources的原因吗

@EightMonth
Copy link
Contributor

@bean
public IdentifierGenerator identifierGenerator() {
return new DefaultIdentifierGenerator(workerId, datacenterId);
}

该ID生成策略为雪花算法,多实例不指定workId, datacenterId可能会造成重复。
在启动类添加以上代码覆盖默认ID生成实现,可使用配置随机生成,再引入上述代码实现动态ID,默认通过网卡或mac码生成

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants