Spring Architecture – An Introduction

Spring Architecture – An Introduction:
Spring is a lightweight framework used to build java applications. In this article let us see the Spring Architecture in detail.


There are seven modules in Spring,

  • Core
  • ORM
  • DAO
  • AOP
  • MVC
  • Application Context
  • Web Context

This forms the base of Spring framework. All the other modules are built over Core module. This module contains Bean factory container which forms the basis to implement Dependency Injection.

Data Access Object – This module provides a standard way for data access. (Hibernate, JDBC etc..).  Normally in an application to access the database we need to opening connection, perform the operation and close the connection. But in Spring DAO, We can overcome this issue’s because Spring takes care of opening and closing of database connections and all we have to do write code to perform the operations.

Object Relational Mapping – This helps us to integrate Spring framework with other Frameworks such as Hibernate, JDO etc.

Aspect Oriented Programming – Helps in implementing aspects within our application. Aspect Oriented Programming helps us to separate application logic from system level services.

Model View Controller – This module helps us to separate application logic from the view.

Application Context:
This module is built over Core Module. Application Context has all the concepts of Bean factory and in addition to those concepts application context has internalization of Messages, life cycle events and validation

Web Context:
Web Context is a part of web application which includes MVC module.

Read More

Maven – Profiles – Profile based Dependencies

Maven – Profiles – Profile based Dependencies:
One of the major advantage of maven is creating profile based dependencies. Instead of creating separate POM.xml, we can create a profile and configure dependencies for that specific profile. This helps us to declare all the dependencies in one pom.xml.

There are various ways of creating Profiles in Maven, declaring in POM.xml or declaring in settings.xml etc. Here we are going to see how to create multiple profiles in pom.xml
We can create multiple profiles by declaring id inside <profile> </profile> tag. This <profile> tag should be enclosed between <profiles></profiles> tag.

Creating profile,

In this above code, We have created a profile with name User1 and declared spring dependency for that specific user.

Now let us create 2 profiles and configure dependencies for both the profiles and let us see the output.


In the above pom.xml, We have created 2 users, User1 and User2. User1 has dependency included for emails and User2 for Spring context. After the project is run with Build with Dependencies, When we select a specific profile, Dependencies for that specific profile only to be shown.

First let us see how to select the specific profile using Netbeans.

Right click the project and when we select Set Configuration, We will be able to see the profiles created for that specific project.



We have created User1 and User2 profiles. Now when we select the User1, email dependency downloads to be shown and when we select User2 Spring-context dependency donwloads to be shown.

User1 output:

User2 Output:

Read More

Maven – Configuring Dependencies

Maven – Configuring Dependencies:
When we create a maven project, By default pom.xml will be generated.


Model Version:
Model Version is the version of POM model

Artifact Id:
Contains the name of the project which we create

Group Id:
GroupId is an unique id for the project.

Version is the version number of the project. A project might have multiple releases, So the version number indicates the version release of the project

Type of project packaging.

Now let us include a dependency inside the project, We can get the dependencies here – Maven Repository

Let us include Spring context dependency and check for the dependency download.
Let us include this dependency inside POM.xml

Before we include this dependency, The dependency should be enclosed between <dependencies> tag.

When we right click the project and select “build with dependencies”, the jars are downloaded with the help of these dependencies.



Read More

Maven Overview – Core Concepts

Maven Overview – Core Concepts
What is Maven?
Maven is a Build tool used primarily for Java Projects.

How Maven helps us?
Maven helps us with Builds, dependencies, reporting, documentation and Releases

What is POM?
Whenever we create a maven project, we will have POM.xml file. POM stands for Project Object Model. pom.xml contains information about project configurations, dependencies, plugins, goal, dependencies etc.

Maven Build Cycle:
The Project Object Model (POM) has build life cycle. The Build process in maven consists of Build Life cycles, Phases and Goals.
Build life cycle consists of Sequences of phases to be executed and each phase consists of sequence of goals to be executed

Maven Built-in Build Life Cycles:
Maven has 3 Built-in Build Life Cycles,

  • default
  • clean
  • site

Default: default life cycle performs compiling and packaging the product
clean: clean life cycle removes temporary files, .class files etc
site: generated documentation for the project

Phases of Build Life Cycle:
Now we know that, Build life cycle has sequence of phases to be executed. Maven has alot of sequence of phases. Here are some of the important Phases,

  • Validate: Validates the project and checks all the necessary informations are available
  • Compile: Compiles the source code
  • Test: Tests the source code using suitable unit testing framework
  • Package: Compiled code is packaged in a distributable format (ex: jar)
  • Install: Installs the package in local repository
  • Deploy: Copies the package to remote repository

Build Profiles:
Build profiles are used to build projects with different configurations. This helps us to avoid creating multiple POM.xml files with different configurations.
There are 3 types of Build Profiles,

  • Per user
  • Per project
  • Global

Maven Plugins:
There are two types of plugins in maven,

  • Build Plugin: Executed during build and should be declared within tag <build> tag
  • Reporting Plugin: Executed during Site generation and declared within tag <reporting> tag

Maven Repositories:

  • Local Repository
  • Central Repository
  • Remote Repository

Local Repository: 
It is a directory in our local system. When we run maven it will download the dependencies and will keep those dependencies in our system, So we can re-use the same downloaded dependencies for other projects too.

Central Repository:
Central Repository is provided by Maven Community. Maven looks into central repository when it cannot find the dependencies in the Local Repository

Remote Repository:
Remote Repository is the repository in the web server.

External Dependencies:
These dependencies are the one which are not available in the Local Repository or Central or Remote Repository But available in our Hard disk.

SNAPSHOT Dependencies:
These are the dependencies that are still under development. SNAPSHOT dependencies make sure that we have the latest version on every build.

Read More

Maven Installation Step by Step

What is Maven?
Maven is a project Management tool which provides a complete build life cycle framework.
Maven helps us to manage Builds, dependencies, Documentation, Reporting etc.

In this article let us see how to Install Maven Step by Step.

JAVA_HOME variable to be set in Windows Environment Variable. Right click on My Computer –> Properties –> Advanced System Settings –> Environment Variables

Download Maven (here) and unzip the contents.



We need to create 2 system variables, M2_HOME and MAVEN_HOME and set the path where we have unzipped the maven.


Edit the path variable in environment variables and include %M2_HOME%\bin

Verify the maven installation


Read More