Uploaded image for project: 'Commons BeanUtils'
  1. Commons BeanUtils
  2. BEANUTILS-540

BeanUtils.copyProperties not working in static inner class

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.9.3
    • None
    • Bean / Property Utils
    • None
    • local test

    Description

      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 + "]"; }

      }

      }

       

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            leoLJL Liu Jun Long
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 96h
                96h
                Remaining:
                Remaining Estimate - 96h
                96h
                Logged:
                Time Spent - Not Specified
                Not Specified