[
https://issues.apache.org/jira/browse/BEANUTILS-540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17525825#comment-17525825
]
Ng Tsz Sum commented on BEANUTILS-540:
--------------------------------------
The `copyProperties` will work as expected if the static inner classes are
public.
> BeanUtils.copyProperties not working in static inner class
> -----------------------------------------------------------
>
> Key: BEANUTILS-540
> URL: https://issues.apache.org/jira/browse/BEANUTILS-540
> Project: Commons BeanUtils
> Issue Type: Bug
> Components: Bean / Property Utils
> Affects Versions: 1.9.3
> Environment: local test
> Reporter: Liu Jun Long
> Priority: Major
> Original Estimate: 96h
> Remaining Estimate: 96h
>
> using below funtion copy beans, i have created two static inner class, but
> not copy successfully, then i have created two normal class, it's working
> fine.
> under Spring's package, working fine.
> package com;
> import org.apache.commons.beanutils.BeanUtils;
> //import org.springframework.beans.BeanUtils;
> public class Test {
> public static void main(String[] args) throws Exception {
> // TODO Auto-generated method stub
> Person person = new Person();
> person.setAddress("Shannxi");
> person.setName("Leo1");
> Student student = new Student();
> BeanUtils.copyProperties(student, person);
> System.out.println(student);
> //at firstly create two nomal class Employ and manager
> Employ employ = new Employ();
> employ.setAddress("Shannxi xian");
> employ.setName("Leo1");
> Manager manager = new Manager();
> BeanUtils.copyProperties(manager, employ);
> System.out.println(manager);
> }
> static class Person {
> private String name;
> private String address;
> public String getName() {
> return name;
> }
> public void setName(String name) {
> this.name = name;
> }
> public String getAddress() {
> return address;
> }
> public void setAddress(String address) {
> this.address = address;
> }
> }
> static class Student {
> private String name;
> private String address;
> public String getName() {
> return name;
> }
> public void setName(String name) {
> this.name = name;
> }
> public String getAddress() {
> return address;
> }
> public void setAddress(String address) {
> this.address = address;
> }
> @Override
> public String toString() {
> return "Student [name=" + name + ", address=" + address + "]";
> }
> }
> }
>
>
--
This message was sent by Atlassian Jira
(v8.20.7#820007)