Collection Mapping using bean xml

Collection Mapping using bean xml tutorial will provide us an overview of Spring Java applications. It will also help us to create a Spring application and run it using the Java main class and configuration written in bean.xml.

As part of this blog, we will be able to create, run and see output of our first Spring application project within 10 min. As we all know about developer curiosity, once project setup is start running locally, we are good to try and ready to learn multiple things. This blog is right for you to put your first step towards learning or revise things again.

We will be using Spring Tool Suit to create spring Java application which is nothing but an extension of Eclipse editor as part of this blog using with bean.xml.

To download and setup Spring Tool Kit please click on this link.

Follow below steps to create our very first Spring application project.

1. Open Spring Tool kit we installed here.

2. Click on File in top navigation menu and than click on new. There will be an option Spring Starter Project start appearing once we click on create new option.

Below window will start appearing.

Provide below highlighted value for Group and Artifact for the project and click on Next.

3. In the below screen select open Web option and select Spring Web. Click on Finish will create Spring project.

4. Create User.java class as mentioned in below screenshot with firstName as String, countries as List months as Set, weeks as Map and states as Properties.

5. Create bean.xml under below hierarchy src/main/resources.

6. Place below content inside created bean.xml in above step.

7. In SpringannotationApplication.java class place below line of code to access created variable, List, Map, Set and Properties in User.java class. All the values it will be picking from bean.xml define in above 5 steps.

8. Right click inside SpringannotationApplication.java to run it as a Java application will give below output.

OUTPUT:

Imran Khan

Specialist Master (Architect) with a passion for cutting-edge technologies like AEM (Adobe Experience Manager) and a proven track record of delivering high-quality software solutions.

  • Languages: Java, Python
  • Frameworks: J2EE, Spring, Struts 2.0, Hibernate
  • Web Technologies: React, HTML, CSS
  • Analytics: Adobe Analytics
  • Tools & Technologies: IntelliJ, JIRA

🌐 LinkedIn

📝 Blogs

📧 Imran Khan