Hello. I have this situation - there is a class, it declares one public constructor (without parameters) and one protected - with parameters. I need one that is protected with parameters. I inherit from the original class, I define the public constructor in it, and from there I call the protected constructor of the base class, but Spring, when I raise my bin (the inherited class), it says the designer is not public . This situation can somehow get around?

Code:

 public class MultiValueMapContainer extends MultiValueMap { private int queueCapacity; public MultiValueMapContainer(int queueCapacity) { super(new HashMap(), new InstantiateFactory(ArrayBlockingQueue.class, new Class[]{Integer.class}, new Object[]{queueCapacity})); this.queueCapacity = queueCapacity; } public int getQueueCapacity() { return queueCapacity; }} 

In MultiValueMap :

 protected MultiValueMap(java.util.Map map, Factory collectionFactory) 

The InstantiateFactory constructor is public :

 <bean name="MyMap" class="package.MultiValueMapContainer"> <constructor-arg type="int" value="${initialSeriesCount}"/> </bean> 
  • You can try to create a private method instead of a constructor and access it by getters and setters. - Gorets
  • 2
    The text would be software. You can usually use it this way if you have: class A {protected A (int i) {// ...}; } class B extends A {public B (int i) {super (i); // work A a = new A (i); // fail}; } - Dex
  • provide the general code of your constructors and the context configuration - yozh
  • Everything is exactly the same for me - it doesn't work. Updated question - Vladimir
  • Strange, your simplified example works great. And the exact text of the error can be? - Dex

1 answer 1

Integer.class -> int.class

Reason: since there is obviously reflection used inside the InstantiateFactory constructor, the parameters indicating the types of the constructor arguments must be exact - although int can be autopacked to Integer , int.class is not related to Integer.class .

  • Thank. I did not think that when using reflection packs do not sink. Well, it is basically logical. - Vladimir