Store class HashMap Spring Example

Store class HashMap Spring Example

Spring provide many functionality which can be configured and access at run time through beans. Here I will show you how to store classes in HashMap and access it at runtime.

We will use below two classes which will implement same interface:

  • TestInterface.java:

  • TestInterfaceImpl.java:

  • TestInterfaceImpl2.java:

  • Now define bean for it and store in HashMap as below:

You could access HashMap and its classes as below:

  • AccessClassesHashMap.java:

Reference:

Leave a Reply

Your email address will not be published. Required fields are marked *