JumpStart with JAVA Frameworks | MVC, Spring, RESTful Services

March 15, 2017
3 mins read

So, as you already have some hands-on with JAVA development, let’s do move forward and play with JAVA Frameworks. There are different frameworks available in JAVA. Each framework has its own pros and cons. Developers can use any framework as per then need, requirement and ease.

Here, we’ll be talking about MVC and Spring along with RESTful services.

Maven;

Maven is the software project management and comprehension tool based on POM (project object model).  It is used for projects build, dependency and documentation. It simplifies the build process like ANT. But it is too much advanced than ANT.

As per Wikipedia definition, “Maven is a build automation tool used primarily for Java projects. The word maven means “accumulator of knowledge” in Yiddish. Maven addresses two aspects of building software: first, it describes how software is built, and second, it describes its dependencies.”

The primary goals as follows:

  • Easing the build process
  • Providing a uniform build system
  • Providing quality project information
  • Providing guidelines for best practice development
  • Allowing transparent migration to new features

In order to achieve the preceding goals, Maven provides a set of build standards, an artifact repository model, an engine that describes projects, and a standard lifecycle to build, test, and deploy project artifacts.

Technical Overview;

Maven Component Architecture can be shown here;

Maven provides developers a complete build lifecycle framework.

So, Lets start playing with it Maven;

Simply start your Eclipse EDI and go to create new project, search for Maven, select Maven Project and click Next;

For now, we’re going to play with Simple Project, so select the first checkbox and click Next;

Now, simply give that Group ID and Artifact ID along with required fields and click Finish.

And Eclipse will create the project for us in few seconds.

Now if we open the pom.xml file then it will show us the overview of the pom.xml file;

Now if we click upon pom.xml then we can see the xml code of the file. Here we can see four major elements including moel Version, groupId, artifactid, version and packaging;

Now let’s create a sample class to understand how this Maven Project works better. Simply select the scr/main/java package and by going to New->Project, create a new class here;

Now let’s create a very basic method here;

Now from src/test/java package and go to New->Other, simply and search JUnit category and create a JUnit test case for our Project;

Now simply give package name and required information and click finish;

Now, as soon we will hit finish, it will create the class along with sample test;

In normal cases, when we’re not using Mavan as our build management system, a developer need to download this jar file and add it to the build path every time.

Now to add dependencies, we simply move back to pom.xml file and add dependencies;

Now to define dependencies for JUNIT or any other thing, you don’t have to remember the code for everything. Maven makes your life so much easier.

Simply Google Maven JUNIT dependency which we are looking for right now, get the appropriate link of Maven repository and you can see the latest code snippet of JUNIT dependencies;

Now simply take the snippet from there and insert into the dependencies tag;

Here, we can see this dependency contain groupId, artifactId, and version of JUNIT.

Now, as soon we save the changes, a library will add and a folder name Maven Dependencies will add to our project;

And inside that folder we’ve junit jar file.

And vise-versa, if you remove the dependencies, this folder will automatically remove. : – )

Now lets play with sample web project through Maven. : – )

Simply create a maven project as before, but this time we keep everything default during the creation of the project;

Now simply filter the WebApp from the projects and hit next;

Now, simply give the required credentials and hit Finish;

And you’ll see the Maven Project created for you in few moments. BTW, on Maven Projects you can see the capital ‘M’ over the project icon;

So, pom.xml file contain all dependencies for our app. So, let’s open that;

Now, let’s do run the Web Application. Now to do that, we need a webserver. So for that, we are using local server, i.e Tomcat;

* You will need Eclipse EE edition to configure local server.

Now, as your Tomcap should already installed and configured with Eclipse, simply go to Windows–>ShowView–>Other and search for Server and click ok. It will open a new window for you.

Now as we can see, there is no server available. So simply do right click on create a new server, select the server and hit finish;

And this will add the Topcat server at local host;

Now, as we can see the server is stopped, so simply start the Server;

Now to configure the project with server, simply do the right click and go to Add or Remove.

Now, simply add the project to server which we already created;

Now, simply run the application for testing. And you will get the output on the local host URL;

Now Lets Play with Spring Web MVC framework Here;

Data Scientist & Solution Architect || IBM Recognised Speaker, Mentor, and Teacher || Debater || Blogger || Guinness World Record Holder || Watson Solution Developer || IBM Community Activist || Aspiring to Inspire.

Leave a Reply

Your email address will not be published.

Previous Story

JumpStart with JAVA | For Dot NET Developers

Next Story

JumpStart with JAVA Frameworks | MVC, Spring, RESTful Services

Latest from Blog

Quantum Computing | What, Why & How

Now as we are starting the 5th decade after the very first proposed model in the 1980s, quantum computers are now commercially available, brought out of the lab, and into the industry by IBM Quantum. With many experts predicting it will revolutionize the way we approach problem-solving. With the recent

Case Study: Digital Transformation of “justSajid Bank”

In this current era of what we call “digital first”, industries are repeatedly changing and evolving with the help of technology. So as the banking industry is reshaping itself, banks need to keep adopting positive changes to counter and overcome the key challenges of the modern world to overcome the

Metaverse || A Whole New World.

Things are going to be super dramatic in the next few years. Metaverse is going to open a lot of new doors to revise things that we are doing now. The culture and lifestyle would be changed. Some new cultures would have emerged and everybody would be living without physical

Pakistan Day 2020 | Coronavirus Technical Solutions

Well, on Pakistan Day 2020 our nation along with the rest of the world is facing Corona Pandemic. As the sons of this great motherland, we are trying to play our roles at our places. Within the last few weeks, Alhamdulillah I’ve got a chance to develop two technical solutions

Password: Choose the Secure, Easy and Cool Password

A super secure Password is very common nowadays. Although according to experts the password is going to expire very soon. Moreover, the pin codes are also replacing password in some why. Perhaps still there is a lot of importance of a secure password in many places. The one of the most

JumpStart with DevOps

What is DevOps; DevOps is a Software Development Strategy, that bridges the gap between the Dev and the Ops side of the company. * It’s not a tool, it’s a Methodology to bridge the gap b/w development and operations teams! As there is always a lot of conflicts between the

JumpStart Programming with Python 3

Motivation; Well, if you want to play with data and deal with complex analytics problems then Python is the best for you. We can use Python for developing complex scientific and numeric apps. Python is designed with features to facilitate data analysis and visualization. The syntax in Python helps the programmers to do coding

Understanding of Data Science Methodology

Motivation: It’s all about the different methods used in data science. Data Science Methodology: There is the following methodology used in data science which can further categories into different phases; From Problem to Approach Business Understanding Analytical Approach Working with Data Data Requirements Data Collection Data Understanding Data Preparation Deriving the

Understanding Machine Learning Methodology

Motivation Well, if we talk about a human cell sample extracted from a patient. The cell would have some characteristics. One of the interesting questions we can ask, what kind of statistics that cell have? One could easily presume that only a doctor with years of experience could diagnose a tumor and

SIMPLE NAVIGATION IN WINDOWS APPLICATION

The Navigation of UWP Apps is extremely cool and easier than other platforms. It allows enabling a variety of intuitive user experiences for moving between apps, pages, and content. Navigation is the key part of the Application. In your small Apps, you may maintain your contents and functionality in a

UNDERSTANDING THE ARCHITECTURE OF UNIVERSAL WINDOWS PLATFORM

The architecture of Universal Windows Platform is most exclusive with the center of gravity which is One Windows Core. Now the whole development will follow the common refactored core that will common for all the windows Releases. It’s all about One Core, One Hardware Platform, Universal Hardware Driver and Standalone

Guinness World Record Holder | Hajj Hackathon | Khadim Al-Haramain Al-Sharifain

Khadim Al-Haramain Al-Sharifain Built an MVP of a cognitive platform name “Khadim Al-Haramain Al-Sharifain“.  Objective The objective was to facilitate Hajj operations by introducing cognitive services integrated with Hajj systems. Hence millions of Muslims who are there for Allah Rab-ul-Izat, can perform anything without disturbing their focuses and concentrations.  Functionalities

JumpStart with IBM Bluemix

IBM Bluemix is the world most exclusive cloud platform that provides developers to quickly develop, Deploy and manage Apps over the cloud without dealing with any underline infrastructure. Bluemix provides great open source platforms for your needs. Tech experts believe that up to 2020 the computing era would completely change.

JumpStart Into Big Data With HDInsight

What would happen when the volume of your data increased repeatedly over time and you need high velocity at the same time. Not only that but you have a different variety of data and Variability also exists in your data. So how would you handle all that data? If we

Microsoft SharePoint: Create an Intranet in SharePoint

As you should already have some hands on with SharePoint. So, Lets do some hands on with SharePoint Intranet for Small company. Simply start with a Blank Site Collection. Let’s assume that the company has 3 Departments: Sales, Production and Support. They each have their own area in which they should

.NET Core

.NET Core 1.0  .NET Core 1.0 is a major new investment in the future of .NET and laying the foundation for decades to come. Still, it is in its early stage, and for some time you might still focus .NET Framework 4.6 depending on your application needs. But for many scenarios,

JUMPSTART WITH DATA BINDING IN UWP

Data Binding is one of the most interesting topics in Universal App Development. In order to perform the better functionality, you really need to have some great usage of Data Binding in you Apps. So! First thing first. What is actually the Data Binding and is its usage in UWP.

justSajid | A PLACE FOR MY THOUGHTS

This blog is my personal mental playground. The views expressed are mine, and mine alone. They do not represent the views of my employer, my family, my friends, my imaginary friends, my neighbors, people who live in my city, province, country, region, or planet, nor do they represent the views

justSajid | A PLACE FOR MY THOUGHTS

justSajid is my personal mental playground. The views expressed are mine, and mine alone. They do not represent the views of my employer, my family, my friends, my imaginary friends, my neighbors, people who live in my city, province, country, region, or planet, nor do they represent the views of

Agentic AI: The Future of Machines Acting with Purpose

Artificial Intelligence (AI) has come a long way from being a fancy algorithm for chess games to becoming our digital assistant, creative collaborator, and even a philosopher’s muse. One of the more intriguing advancements in AI is Agentic AI—an AI system that can act autonomously, pursue goals, and make decisions,
GoUp