Project Setup and Collection Mapping Using Bean.xml

This blog will provide you with an overview of Spring Java applications. It will also help you 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.

OUTPUT:

Imran Khan, Adobe Community Advisor, AEM certified developer and Java Geek, is an experienced AEM developer with over 11 years of expertise in designing and implementing robust web applications. He leverages Adobe Experience Manager, Analytics, and Target to create dynamic digital experiences. Imran possesses extensive expertise in J2EE, Sightly, Struts 2.0, Spring, Hibernate, JPA, React, HTML, jQuery, and JavaScript.

0