About BeanUtils class In Spring Framework

Sanjay Singh
Sep 2, 2021

--

https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/beans/BeanUtils.html

Static convenience methods for JavaBeans: for instantiating beans, checking bean property types, copying bean properties, etc.

Case 1- when you need to copy field value from one object to another object

public ProductAggregate(CreateProductCommand createProductCommand) {

ProductCreatedEvent productCreatedEvent = new ProductCreatedEvent();
BeanUtils.copyProperties(createProductCommand,productCreatedEvent);

}
// CreateProductCommand object value copy in ProductCreatedEvent
Copy the property values of the given source bean into the target bean.

--

--

Sanjay Singh
Sanjay Singh

Written by Sanjay Singh

Java, Spring Boot & Microservices developer Sharing knowledge, tutorials & coding tips on my Medium page. Follow me for insights & see story list section

No responses yet