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

使用Lombok的@Accessors(chain = true)之后, 无法copy #3525

Closed
songhanlin opened this issue Mar 26, 2024 · 1 comment
Closed

使用Lombok的@Accessors(chain = true)之后, 无法copy #3525

songhanlin opened this issue Mar 26, 2024 · 1 comment
Labels

Comments

@songhanlin
Copy link

版本情况

JDK版本: jdk17
hutool版本: 5.8.26(请确保最新尝试是否还有问题)

问题描述(包括截图)

  1. 复现代码
@Data
@Accessors(chain = true)
 class SampleBean {
    private String value;
}
@Data
@Accessors(chain = true)
 class OtherSampleBean {
    private String value;
}

SampleBean bean1 = new SampleBean();
bean1.setValue("Hello world");

OtherSampleBean otherBean = new OtherSampleBean();

CglibUtil.copy(bean1, otherBean);

System.out.println(otherBean.getValue()); // 为空
  1. 堆栈信息

  2. 测试涉及到的文件(注意脱密)

image

比如报错的Excel文件,有问题的图片等。

@looly
Copy link
Member

looly commented Mar 26, 2024

这个是Cglib和Lombok的兼容问题,Cglib的拷贝不支持返回this的setter方法,因此不能识别。

考虑使用BeanUtil.copyProperties.

@looly looly closed this as completed Mar 26, 2024
@looly looly added the question label Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants