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

使用了builder模式之后,怎么映射数据库对象的? #4

Open
tufoWang opened this issue Oct 9, 2019 · 1 comment
Open

Comments

@tufoWang
Copy link

tufoWang commented Oct 9, 2019

Order对象使用了Builder模式,被lombok的@builder修饰,在OrderRepository中的byId方法中使用了return (rs, rowNum) -> objectMapper.readValue(rs.getString("JSON_CONTENT"), Order.class);
由于使用Builder模式,会生成全参数的构造函数,在对此对象赋值的时候,报错,没有无参的构造函数。
盼复!

@davenkin
Copy link
Contributor

我本地运行./local-build.sh是ok的,参考项目中的lombok.config文件,其中的"lombok.anyConstructor.addConstructorProperties=true"会为全参构造函数自动生成"@java.beans.ConstructorProperties“进而让jackson自动找到该全参构造函数而不是默认构造函数。所以,是不是你IDE中的lombok没有配置对?

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